CNIT 315 EXAM 2 QUESTIONS AND ANSWERS
1. Why does a pointer have to point back to the same type?- Answers - It is self-
referencing
2. Insertion Sort- Answers - Has a key value, doesn't swap every out of place numbers, only swaps the
biggest number that's out of order, faster than bubble sort.
3. Bubble Sort- Answers - slowest sort, higher numbers bubble up to top, like champaign
4. Selection sort- Answers - The smallest value is initially selected from the complete list of data and exchanged
with the first element in the list. The same thing happens with the next smallest value on the list. which gets exchanged with
the second smallest element on the list.
5. Why Does Null not need memory refrence?- Answers - It's a special character that signifies end
of list
6. Computer memory one dimensional array- Answers - Val 0 --> val 1 --> val 2 --> ...val n Value
by Value
7. computer memory two dimensional array- Answers - val 0 --> row 1 ..> row 2 --> ...row n row by
row
8. What makes sorts expensive?- Answers - How
often you swap data Writing to memory takes a lot of resources
9. Linked lists requirement- Answers - need a start pointer
10. Which is correct for the following pointer- Answers - struct
Node *Start; Start = NULL or Start.Next = NULL?- Answers -
Start = NULL
11. Malloc () Function- Answers - Allocates space, can be used interchangeably with Calloc () function,
The space allocated for this function comes from the computer's heap
12. Malloc () Function Purpose- Answers - is the more general purpose of two functions.
,13. Calloc () Function- Answers - Reserves space of array, can be used interchangeably with Malloc () function.
Initializes the allocated memory to all zeros and malloc does not.
14. Calloc () Function Advantage- Answers - It initializes all newly allocated numeric memory to 0 and
character allocated memory to NULL.
15. Realloc () Function- Answers - relocating
16. Free () Function- Answers - clean up memory
17. type def () Function- Answers - struct
18. Traverse Function- Answers - crossover, go to start and go til end, visit every node of list
19. display Function- Answers - print out content of each node
20. Binary Search- Answers - logarithmic algorithm, data gets bigger, grows ditterently
0(log2n)
21. Linear Search- Answers - (Also known as sequential search) Each item on list is examined in the order it
occurs until desired amount is located or the end of list is reached.
, 22. NULL Character- Answers - escape sequence, 10 is automatically appended to all strings by the compiler.
23. Three Dimensional Arrays- Answers - Can be viewed as a book of data tables (third subscript is called
the rank)
24. Data Structures- Answers - Every search you do
25. Static Structures- Answers - Fixed Size (don't change), like arrays
26. Dynamic Structures- Answers - Variable Size, grows and shrinks, less ettort,
more overhead "array list" <- not any array because it can have 0 elements
27. Memory Allocation- Answers - Created during compile time
28. Dynamic Allocation- Answers - Memory requests are made for allocation and releases memory space
while the program runs (also known as Run-time allocation).
29. Linked List- Answers - grows and shrinks, depend on what your doing, set of structures , (a.k.a. Self-
referencing structure)
30. Stack- Answers - Special type of linked list in which objects can only be added to and removed from the top of
the list - Last-in, First-out (LIFO) list.
in a true stack, the only item that can be seen and accessed is the top item.
31. Push- Answers - Put things on a stack, can push unlimited amount of things other than the physical limit of
computer. Is basically AddFront
32. Pop- Answers - Take things ott a stack, limit is the number of elements in the list. Is basically a Delete Node
33. Destructive (alter-stack)- Answers - Pop and Push
34. Non-Destructive (Don't alter-stack)- Answers - Peek, IsEmpty, Size
35. IsEmpty (function)- Answers - returns false, > 1 Element, is tied to Pop, Dequeue and size.
36. Peek- Answers - Sees value at top of stack, doesn't change anything, basically an indirection operator
37. Queues- Answers - Relies on linked structures, items are removed from a queue in the order in which they were
entered. First-in, First-out (FIFO) structure
1. Why does a pointer have to point back to the same type?- Answers - It is self-
referencing
2. Insertion Sort- Answers - Has a key value, doesn't swap every out of place numbers, only swaps the
biggest number that's out of order, faster than bubble sort.
3. Bubble Sort- Answers - slowest sort, higher numbers bubble up to top, like champaign
4. Selection sort- Answers - The smallest value is initially selected from the complete list of data and exchanged
with the first element in the list. The same thing happens with the next smallest value on the list. which gets exchanged with
the second smallest element on the list.
5. Why Does Null not need memory refrence?- Answers - It's a special character that signifies end
of list
6. Computer memory one dimensional array- Answers - Val 0 --> val 1 --> val 2 --> ...val n Value
by Value
7. computer memory two dimensional array- Answers - val 0 --> row 1 ..> row 2 --> ...row n row by
row
8. What makes sorts expensive?- Answers - How
often you swap data Writing to memory takes a lot of resources
9. Linked lists requirement- Answers - need a start pointer
10. Which is correct for the following pointer- Answers - struct
Node *Start; Start = NULL or Start.Next = NULL?- Answers -
Start = NULL
11. Malloc () Function- Answers - Allocates space, can be used interchangeably with Calloc () function,
The space allocated for this function comes from the computer's heap
12. Malloc () Function Purpose- Answers - is the more general purpose of two functions.
,13. Calloc () Function- Answers - Reserves space of array, can be used interchangeably with Malloc () function.
Initializes the allocated memory to all zeros and malloc does not.
14. Calloc () Function Advantage- Answers - It initializes all newly allocated numeric memory to 0 and
character allocated memory to NULL.
15. Realloc () Function- Answers - relocating
16. Free () Function- Answers - clean up memory
17. type def () Function- Answers - struct
18. Traverse Function- Answers - crossover, go to start and go til end, visit every node of list
19. display Function- Answers - print out content of each node
20. Binary Search- Answers - logarithmic algorithm, data gets bigger, grows ditterently
0(log2n)
21. Linear Search- Answers - (Also known as sequential search) Each item on list is examined in the order it
occurs until desired amount is located or the end of list is reached.
, 22. NULL Character- Answers - escape sequence, 10 is automatically appended to all strings by the compiler.
23. Three Dimensional Arrays- Answers - Can be viewed as a book of data tables (third subscript is called
the rank)
24. Data Structures- Answers - Every search you do
25. Static Structures- Answers - Fixed Size (don't change), like arrays
26. Dynamic Structures- Answers - Variable Size, grows and shrinks, less ettort,
more overhead "array list" <- not any array because it can have 0 elements
27. Memory Allocation- Answers - Created during compile time
28. Dynamic Allocation- Answers - Memory requests are made for allocation and releases memory space
while the program runs (also known as Run-time allocation).
29. Linked List- Answers - grows and shrinks, depend on what your doing, set of structures , (a.k.a. Self-
referencing structure)
30. Stack- Answers - Special type of linked list in which objects can only be added to and removed from the top of
the list - Last-in, First-out (LIFO) list.
in a true stack, the only item that can be seen and accessed is the top item.
31. Push- Answers - Put things on a stack, can push unlimited amount of things other than the physical limit of
computer. Is basically AddFront
32. Pop- Answers - Take things ott a stack, limit is the number of elements in the list. Is basically a Delete Node
33. Destructive (alter-stack)- Answers - Pop and Push
34. Non-Destructive (Don't alter-stack)- Answers - Peek, IsEmpty, Size
35. IsEmpty (function)- Answers - returns false, > 1 Element, is tied to Pop, Dequeue and size.
36. Peek- Answers - Sees value at top of stack, doesn't change anything, basically an indirection operator
37. Queues- Answers - Relies on linked structures, items are removed from a queue in the order in which they were
entered. First-in, First-out (FIFO) structure