Study Guide and General Questions Help?

Hey guys I have an exam coming up soon and was wondering if you guys could assist me with some of the questions on our study guide so that I can learn and study the correct answers. Thank you for all whom help or lead me to the right answers! Anything will help, links explaining how something works, etc.

PLEASE CORRECT ME IF I AM WRONG IN ANY OF MY ANSWERS! THANK YOU!

How is declaring an integer different than declaring a pointer to an integer?

My thoughts: A pointer to an integer points to some address in memory?

What is the code to cout the address (reference) of an integer named my_number?

My thoughts: &my_number

What is the code to cout the value that an integer pointer name my_ptr is pointing to?

My thoughts: *my_ptr

A/an ____ is a wrapper around a pointer which allows access to a variety of generic containers.

My thoughts: Not sure

What is the time in terms of Big O for the following vector operations:
Insertion, Deletion, Access. Front, Middle, Back.

My Thoughts: Not sure

The___ is called automatically when a class object is created, while the ____ is called automatically when a class object goes out of scope.

Blank 1: Constructor Blank 2: Destructor

What is it called when there's dynamic memory allocated that can no longer be accessed by the program?

My thoughts: Memory Leak?

What is the difference between an Abstract Data Types(ADT)and a Data Structure?

My thoughts: Not sure

Express each time in terms of Big O notation:
Constant, linear, logarithmic, polynomial, exponential

My thoughts: No idea

Why is a push_front method on a vector a more time consuming task then push_back?

My thoughts: Push_back requires more time to identify how many objects to be placed before? Kinda iffy on this one

A cstring is a simply a ____?

My thoughts: Character Array?

This data type allows strings to have stream functionality

My thoughts: String Stream

Give the code for a resize() function for a vector

#include <iostream>
#include <vector>
using namespace std;
int main ()
{
vector<int> myvector;

for (int i=1;i<10;i++) myvector.push_back(i);

myvector.resize(5);

return 0;
}



Once again thank you to anyone who took the time to help me out with these questions.
Hi,

Just some ideas:

Q1. show actual code examples for both of those.

Q2. std::cout << &my_number // you had half of it ...

Q3 similar to Q2

Q4 The last part is a little misleading, but what is something very closely related to a pointer? Starts with r.

Express each time in terms of Big O notation:
Constant, linear, logarithmic, polynomial, exponential


Do these look familar? O(1) , O(N) etc,
I'll continue from where TheIdeasMan stopped.

Q5: In addition to TheIdeasMan answer, you can check Standaed mandated complexity using some reference material. http://en.cppreference.com/w/ has a complexity entry almost for eack operation.

Q6: You are correct

Q7: Yes, this is memory leak

Q8: Did you try searching first? In short ADT are data model from user point of view (example: signed char is an integral value with size of 1, which can have values [-128; 127] and outputs character which code it contains), data structures describes data mode from the point of view of implementer (signed char is a 8-bit 2-complement number, and there is a set of funtions overloaded for char)

Q9: Try to google: https://en.wikipedia.org/wiki/Time_complexity

Q10: "There are 4 branches on each birch tree. There are 3 apples on each branch. How many apples you could gather from a single birch tree?" vector does not have a push_front method. If it did have, then it would be slow, because of logic similar to yours (although you got it backward, reread your class notes, especially on how insertion in the back happens)

Q11: More precisely a null-terminated character array

Q12: yes

Q13: Do you need to show how resize is used or how it can be implemented?
@MiiNiPaa

Just wanted to mention that I didn't answer all the questions on purpose - I had a dinner appointment :+)

Regards
Topic archived. No new replies allowed.