0% found this document useful (1 vote)
505 views17 pages

CIT 216 Data Structures Exam Guide

The document outlines the exam questions and answers for the CIT 216 course on Data Structures, covering foundational concepts, arrays, linked lists, stacks, queues, hashing, trees, garbage collection, memory allocation, Java programming, and algorithms. Each unit includes multiple-choice questions and true/false statements, with correct answers provided. The content emphasizes key principles and definitions related to data structures, programming concepts, and algorithm design.

Uploaded by

salihubarup
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (1 vote)
505 views17 pages

CIT 216 Data Structures Exam Guide

The document outlines the exam questions and answers for the CIT 216 course on Data Structures, covering foundational concepts, arrays, linked lists, stacks, queues, hashing, trees, garbage collection, memory allocation, Java programming, and algorithms. Each unit includes multiple-choice questions and true/false statements, with correct answers provided. The content emphasizes key principles and definitions related to data structures, programming concepts, and algorithm design.

Uploaded by

salihubarup
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

CIT 216: Fundamentals of Data Structures - NOUN Exam

Questions
Module 1: Foundational Data Structures

Unit 1: Fundamentals

1. What is a data structure?

2. A) A programming language

3. B) A way to organize and store data for efficient operations

4. C) A type of algorithm

5. D) A hardware component

6. Answer: B

7. Which of the following is a linear data structure?

A) Tree

B) Graph

C) Array

D) Hash Table

Answer: C

8. True or False: Time complexity measures the amount of memory used by a data
structure.

Answer: False

9. What does O(1) time complexity represent?

A) Linear time

B) Constant time

C) Quadratic time

D) Logarithmic time
Answer: B

Unit 2: Arrays

5. What is an array?
A) A dynamic collection of elements
B) A fixed-size collection of elements of the same type
C) A hierarchical data structure
D) A key-value pair structure
Answer: B
6. What is the index of the first element in an array?
A) 1
B) 0
C) -1
D) 2
Answer: B
7. What is the time complexity of accessing an element in an array?
A) O(n)
B) O(log n)
C) O(1)
D) O(n²)
Answer: C
8. True or False: Arrays are stored in non-contiguous memory locations.
Answer: False

Unit 3: The List Data Structure

9. Which type of linked list allows traversal in both directions?


A) Singly Linked List
B) Doubly Linked List
C) Circular Linked List
D) Binary Linked List
Answer: B
10. What is the operation to add an element at the end of a linked list called?
A) Insert
B) Append
C) Push
D) Enqueue
Answer: B
11. True or False: A circular linked list has a last node that points to the first node.
Answer: True
12. What is a key advantage of a linked list over an array?
A) Fixed size
B) Dynamic size
C) Faster access time
D) Contiguous memory
Answer: B

Unit 4: The Stack Data Structure

13. Which principle does a stack follow?


A) FIFO
B) LIFO
C) LILO
D) FILO
Answer: B
14. What is the operation to add an element to a stack?
A) Pop
B) Push
C) Enqueue
D) Dequeue
Answer: B
15. What happens when a stack is full and you try to push an element?
A) Stack overflow
B) Stack underflow
C) No error
D) Element is added
Answer: A
16. True or False: A stack can be implemented using an array or a linked list.
Answer: True

Unit 5: The Queue Data Structure

17. Which principle does a queue follow?


A) LIFO
B) FIFO
C) LILO
D) FILO
Answer: B
18. What is the operation to remove an element from a queue?
A) Push
B) Pop
C) Enqueue
D) Dequeue
Answer: D
19. What is a priority queue?
A) A queue with elements in random order
B) A queue where elements are processed based on priority
C) A queue with fixed size
D) A queue with no order
Answer: B
20. True or False: A deque allows elements to be added or removed from both ends.
Answer: True

Module 2: Hashing and Trees

Unit 1: Hashing

21. What does a hash function do?


A) Encrypts data
B) Maps data to a fixed-size value
C) Sorts data
D) Deletes data
Answer: B
22. What is a collision in hashing?
A) Two keys mapping to the same hash value
B) A key with no value
C) A hash table overflow
D) A missing key
Answer: A
23. Which technique resolves collisions by using a linked list?
A) Linear Probing
B) Quadratic Probing
C) Separate Chaining
D) Double Hashing
Answer: C
24. True or False: A hash table provides O(1) average-case time complexity for lookups.
Answer: True

Unit 2: Trees

25. What is the topmost node of a tree called?


A) Leaf
B) Root
C) Branch
D) Child
Answer: B
26. A node with no children is called a ______.
A) Root
B) Parent
C) Leaf
D) Sibling
Answer: C
27. What is the height of a tree?
A) Number of nodes
B) Longest path from root to leaf
C) Number of edges
D) Number of levels
Answer: B
28. True or False: A binary tree can have at most two children per node.
Answer: True

Unit 3: Search Trees

29. What is a binary search tree?


A) A tree with nodes in random order
B) A tree where left subtree has smaller values than the right
C) A tree with multiple children per node
D) A tree with no children
Answer: B
30. Which tree maintains balance for O(log n) operations?
A) Binary Tree
B) AVL Tree
C) B-Tree
D) Heap
Answer: B
31. What is the purpose of a B-Tree?
A) Storing key-value pairs
B) Efficient searching in databases
C) Graph traversal
D) Sorting arrays
Answer: B
32. True or False: A binary search tree guarantees O(log n) search time in all cases.
Answer: False

Unit 4: Garbage Collection

33. What is garbage collection?


A) Sorting data
B) Reclaiming unused memory
C) Allocating memory
D) Compressing data
Answer: B
34. Which algorithm identifies unreachable objects in memory?
A) Quick Sort
B) Mark-and-Sweep
C) Dijkstra’s Algorithm
D) Merge Sort
Answer: B
35. True or False: Garbage collection prevents memory leaks.
Answer: True

Unit 5: Memory Allocation

36. Which memory area is used for dynamic allocation?


A) Stack
B) Heap
C) Register
D) Cache
Answer: B
37. In C, which function allocates memory dynamically?
A) free()
B) malloc()
C) sizeof()
D) calloc()
Answer: B
38. What is the purpose of the free() function in C?
A) Allocate memory
B) Deallocate memory
C) Resize memory
D) Initialize memory
Answer: B
39. True or False: Stack memory is used for local variables in functions.
Answer: True

Module 3: Introduction to Java Programming

Unit 1: Object-Oriented Programming Concepts

40. What is encapsulation?


A) Hiding internal details and exposing only necessary information
B) Inheriting from multiple classes
C) Creating multiple object forms
D) Sorting objects
Answer: A
41. What is inheritance in Java?
A) Creating objects
B) Allowing a class to inherit properties from another
C) Defining abstract methods
D) Hiding data
Answer: B
42. What is polymorphism?
A) Creating a single object
B) Allowing objects to take multiple forms
C) Storing data in arrays
D) Allocating memory
Answer: B
43. True or False: Abstraction reduces complexity by hiding implementation details.
Answer: True
Unit 2: Variables

44. Which type of variable is shared among all instances of a class?


A) Instance
B) Local
C) Static
D) Final
Answer: C
45. What keyword declares a constant in Java?
A) static
B) final
C) volatile
D) transient
Answer: B
46. Where are local variables declared?
A) Inside a class
B) Inside a method
C) Outside a class
D) In an interface
Answer: B

Unit 3: Operators

47. Which operator checks for equality in Java?


A) =
B) ==
C) !=
D) ===
Answer: B
48. What is the logical AND operator in Java?
A) ||
B) &&
C) !
D) &
Answer: B
49. True or False: The bitwise OR operator is |.
Answer: True
Unit 4: Expressions, Statements, and Blocks

50. What is an expression in Java?


A) A complete program
B) A combination that evaluates to a single value
C) A group of methods
D) A loop structure
Answer: B
51. What is a statement in Java?
A) A comment
B) A complete executable command
C) A variable declaration only
D) A method call only
Answer: B
52. What is a block in Java?
A) A single statement
B) A group of statements in curly braces
C) A class definition
D) A loop structure
Answer: B

Unit 5: Control Flow Statements

53. Which statement executes code based on a condition?


A) for
B) if
C) switch
D) while
Answer: B
54. Which loop is best for a known number of iterations?
A) while
B) do-while
C) for
D) switch
Answer: C
55. What does the break statement do?
A) Skips an iteration
B) Exits a loop
C) Continues a loop
D) Restarts a loop
Answer: B
56. True or False: The switch statement can use strings in Java.
Answer: True

Module 4: Java Programming

Unit 1: Classes

57. What is a class in Java?


A) An instance of an object
B) A blueprint for objects
C) A method collection
D) A variable type
Answer: B
58. Which keyword defines a class in Java?
A) class
B) object
C) new
D) public
Answer: A
59. What is a constructor in Java?
A) A method to destroy objects
B) A method called when an object is created
C) A static method
D) A final method
Answer: B

Unit 2: Objects

60. What is an object in Java?


A) A class definition
B) An instance of a class
C) A method
D) A variable
Answer: B
61. Which keyword creates an object in Java?
A) class
B) new
C) static
D) final
Answer: B
62. Where are objects stored in Java?
A) Stack
B) Heap
C) Register
D) Cache
Answer: B

Unit 3: Interfaces and Inheritance

63. What is an interface in Java?


A) A class with methods
B) A contract for classes to implement
C) A type of object
D) A variable type
Answer: B
64. Which keyword is used to implement an interface?
A) extends
B) implements
C) inherits
D) super
Answer: B
65. Which keyword is used to inherit a class?
A) implements
B) extends
C) super
D) this
Answer: B
66. True or False: A class can implement multiple interfaces in Java.
Answer: True

Unit 4: Numbers and Strings

67. Which class handles large integers in Java?


A) Integer
B) BigInteger
C) Double
D) Float
Answer: B
68. Which method converts a string to an integer?
A) toString()
B) parseInt()
C) valueOf()
D) intValue()
Answer: B
69. True or False: The String class in Java is immutable.
Answer: True

Unit 5: Generics

70. What are generics in Java?


A) Type-safe collections
B) Dynamic arrays
C) Abstract classes
D) Static methods
Answer: A
71. What symbol denotes a generic type in Java?
A)
B) [T]
C) {T}
D) (T)
Answer: A
72. True or False: Generics ensure type safety at compile time.
Answer: True

Module 5: Algorithms

Unit 1: Introduction to Algorithms

73. What is an algorithm?


A) A data structure
B) A step-by-step procedure to solve a problem
C) A programming language
D) A memory allocation technique
Answer: B
74. What does time complexity measure?
A) Memory usage
B) Execution time
C) Code length
D) Data size
Answer: B
75. True or False: Space complexity measures the memory used by an algorithm.
Answer: True

Unit 2: Vectors and Matrices

76. What is a vector in algorithms?


A) A two-dimensional array
B) A one-dimensional array
C) A tree structure
D) A graph
Answer: B
77. What is a matrix?roses
A) A single linked list
B) A two-dimensional array
C) A hash table
D) A binary tree
Answer: B
78. What is a common operation performed on matrices?
A) Sorting
B) Multiplication
C) Traversal
D) Hashing
Answer: B

Unit 3: Greedy Algorithm

79. What characterizes a greedy algorithm?


A) It divides problems into subproblems
B) It stores solutions to subproblems
C) It makes locally optimal choices
D) It uses backtracking
Answer: C
80. Which problem is typically solved using a greedy algorithm?
A) Knapsack Problem
B) Activity Selection Problem
C) Traveling Salesman Problem
D) Longest Path Problem
Answer: B

Unit 4: Divide-and-Conquer Algorithm

81. What is a divide-and-conquer algorithm?


A) It makes locally optimal choices
B) It divides a problem into smaller subproblems
C) It stores subproblem solutions
D) It uses a single loop
Answer: B
82. Which sorting algorithm uses divide-and-conquer?
A) Bubble Sort
B) Insertion Sort
C) Merge Sort
D) Selection Sort
Answer: C
83. What is the merge step in a divide-and-conquer algorithm?
A) Dividing the problem
B) Combining solutions of subproblems
C) Choosing the best solution
D) Storing intermediate results
Answer: B

Unit 5: Dynamic Programming Algorithm

84. What is dynamic programming?


A) A sorting technique
B) A method to store subproblem solutions
C) A greedy approach
D) A graph traversal method
Answer: B
85. Which problem is solved using dynamic programming?
A) Activity Selection
B) Knapsack Problem
C) Shortest Path
D) Minimum Spanning Tree
Answer: B
86. What technique does dynamic programming use to reduce time complexity?
A) Recursion
B) Memoization
C) Iteration
D) Sorting
Answer: B

Module 6: Graphs and Sorting

Unit 1: Graph Algorithm

87. What is a graph?


A) A linear data structure
B) A collection of vertices and edges
C) A sorted array
D) A key-value pair
Answer: B
88. Which algorithm explores all neighbors before going deeper?
A) Depth-First Search
B) Breadth-First Search
C) Dijkstra’s Algorithm
D) Prim’s Algorithm
Answer: B
89. True or False: Depth-First Search explores as far as possible along a branch.
Answer: True

Unit 2: Sorting

90. What is sorting?


A) Arranging elements in order
B) Storing elements in a tree
C) Mapping keys to values
D) Traversing a graph
Answer: A
91. What is the best-case time complexity of comparison-based sorting?
A) O(n)
B) O(n log n)
C) O(n²)
D) O(1)
Answer: B
Unit 3: Bubble Sort

92. How does bubble sort work?


A) Selects the minimum element
B) Swaps adjacent elements
C) Divides and merges arrays
D) Inserts elements in place
Answer: B
93. What is the worst-case time complexity of bubble sort?
A) O(n)
B) O(n log n)
C) O(n²)
D) O(log n)
Answer: C

Unit 4: Insertion Sort

94. How does insertion sort work?


A) Swaps adjacent elements
B) Builds a sorted array one element at a time
C) Selects the minimum element
D) Divides and merges arrays
Answer: B
95. When is insertion sort most efficient?
A) Large datasets
B) Small datasets
C) Random datasets
D) Sorted datasets
Answer: B

Unit 5: Selection Sort

96. How does selection sort work?


A) Inserts elements in place
B) Swaps adjacent elements
C) Selects the minimum element each iteration
D) Merges subarrays
Answer: C
97. What is the time complexity of selection sort?
A) O(n)
B) O(n log n)
C) O(n²)
D) O(log n)
Answer: C

Unit 6: Merge Sorting

98. How does merge sort work?


A) Swaps adjacent elements
B) Selects the minimum element
C) Divides and merges arrays
D) Inserts elements in place
Answer: C
99. What is the time complexity of merge sort?
A) O(n)
B) O(n log n)
C) O(n²)
D) O(log n)
Answer: B
100. What is the space complexity of merge sort?
A) O(1)
B) O(n)
C) O(n²)
D) O(log n)
Answer: B

Common questions

Powered by AI

A binary search tree is a specific type of binary tree where each node follows the order property: left children have lesser values, and right children have greater values. This structure supports efficient searching, insertion, and deletion operations, potentially enabling O(log n) operations, but only when balanced. In contrast, a general binary tree does not enforce any ordering, which can lead potentially to O(n) operations .

Time complexity measures the performance of an algorithm in terms of the amount of time it takes relative to the input size, affecting efficiency. Space complexity, on the other hand, assesses the amount of memory or storage needed. While time complexity focuses on execution time, space complexity is concerned with the storage resources required .

Garbage collection prevents memory leaks by automatically reclaiming memory allocated to objects that are no longer reachable or needed, thus freeing resources without manual intervention. The Mark-and-Sweep algorithm is a common method used, which involves marking reachable objects and sweeping away those that are unmarked, hence deemed unreachable and eligible for collection .

A hash function maps data to a fixed-size value, transforming input data into hash values which are used as indexes in a hash table. Collisions, which occur when two keys map to the same hash value, are typically resolved using techniques like separate chaining or open addressing. Separate chaining uses linked lists to manage entries with identical hash indices .

FIFO (First-In-First-Out) refers to the order in which elements are processed, akin to a queue in a waiting line, where elements are dequeued from the front. An example of a FIFO structure is a queue. LIFO (Last-In-First-Out) refers to a stack where the most recently added item is processed first, similar to a stack of plates, with 'push' and 'pop' operations. Examples include the stack data structure .

Merge Sort is more efficient than Bubble Sort for large datasets because it consistently performs at O(n log n) time complexity by dividing and conquering, optimizing data comparisons and movements. Bubble Sort, on the other hand, operates with O(n²) time complexity since it iteratively swaps adjacent elements, leading to multiple passes across the data set, making it inefficient especially for large datasets. Merge Sort's divide-and-conquer approach typically leads to fewer comparisons and moves .

Encapsulation is a fundamental concept in object-oriented programming that bundles data and methods operating on that data into a single unit, or class, while restricting access to certain components. In Java, it allows for defining public methods to interact with private fields, enhancing modularity, and security, making code more manageable and reducing complexity. Encapsulation promotes software development best practices by enabling abstraction and maintaining data integrity .

Arrays provide efficient O(1) access time due to contiguous memory allocation, but they have a fixed size and can be inefficient when growing or shrinking in size. Linked lists offer dynamic size, allowing for efficient insertions and deletions, but they have O(n) access time due to non-contiguous storage, which involves sequential traversal to access elements. Arrays generally use memory more efficiently due to their compact structure; however, linked lists can handle variable-sized data better .

Dynamic programming is preferable in scenarios where the problem involves overlapping subproblems and requires optimized solutions from potential options, such as the Knapsack Problem. It stores solutions for subproblems to prevent redundant calculations. Greedy algorithms are used for simpler problems where a local optimum can lead to a global optimum, such as the Activity Selection Problem. Dynamic programming offers better results for complex scenarios, but at the cost of more memory and time .

The divide-and-conquer technique involves breaking a problem into smaller subproblems, solving them independently, and then combining their solutions. This approach is beneficial in sorting as it enhances efficiency by distributing tasks across smaller datasets. Merge Sort is a classic example, which divides a dataset into halves, sorts them, and merges the sorted halves, resulting in an O(n log n) time complexity. This method is advantageous as it makes efficient use of time compared to traditional O(n²) sorting algorithms .

You might also like