NEC Prep

Data Structures, Database, and Operating Systems

NEC Computer Engineering · 2,994 practice MCQs

The chapter on Data Structures, Database, and Operating Systems is crucial for aspiring engineers preparing for the NEC licensing exam. It covers essential concepts such as linked lists, AVL trees, hash tables, and sorting algorithms, all of which are foundational for efficient programming and system design.

Understanding these topics not only enhances your problem-solving skills but also equips you with the knowledge necessary to tackle real-world engineering challenges. To prepare effectively, engage with the 2994 practice MCQs available in this chapter, focusing on both theoretical concepts and practical applications.

Sample questions with answers

  1. 1.Which operation on a linked-list queue has a time complexity of O(1)?

    • A.Add to the back
    • B.Sort the items
    • C.Insert in the middle
    • D.Find an item

    Why: Adding to the back of a linked-list queue is O(1) because it only involves adjusting pointers without needing to traverse the list.

  2. 2.What is the average time complexity for hash table searches?

    • A.O(n log n)
    • B.O(n)
    • C.O(1)
    • D.O(log n)

    Why: The average time complexity for hash table searches is O(1) because, ideally, it allows direct access to the data using a hash function, making retrieval very fast.

  3. 3.Which statement about AVL trees is INCORRECT?

    • A.They permit any balance factor
    • B.They need at most O(1) rotations for each insertion
    • C.They ensure O(log n) search time
    • D.They maintain a balanced height

    Why: AVL trees must maintain a balance factor of -1, 0, or 1; thus, permitting any balance factor is incorrect as it would violate their balanced nature.

  4. 4.Which sorting algorithm is both in-place and stable?

    • A.Insertion sort
    • B.Heap sort
    • C.Merge sort
    • D.Selection sort

    Why: Insertion sort is both in-place and stable because it sorts the elements by inserting them into their correct position while using minimal additional space and maintaining the relative order of equal elements.

  5. 5.Which data structure is the best choice for priority scheduling tasks?

    • A.Heap
    • B.Queue
    • C.Deque
    • D.Stack

    Why: A heap is the best choice for priority scheduling because it allows efficient retrieval of the highest (or lowest) priority element in logarithmic time.

  6. 6.When does the critical section problem occur in IPC?

    • A.When the CPU is not in use
    • B.When memory is contiguous
    • C.When processes run one after another
    • D.When processes access shared resources at the same time without coordination

    Why: The critical section problem occurs when multiple processes access shared resources simultaneously without proper synchronization, leading to potential data inconsistency.

  7. 7.Methods to prevent deadlock include:

    • A.First-Come, First-Served scheduling
    • B.Priority inversion
    • C.The Banker’s algorithm
    • D.Round-robin scheduling

    Why: The Banker’s algorithm is a method to prevent deadlock by ensuring that resource allocation does not lead to a situation where processes could be left waiting indefinitely.

  8. 8.The algorithms for finding minimum spanning trees are classified as:

    • A.Divide and conquer
    • B.Greedy
    • C.Backtracking
    • D.Dynamic programming

    Why: Minimum spanning tree algorithms are classified as greedy because they build the tree step-by-step, always choosing the next edge with the smallest weight that doesn't form a cycle.

  9. 9.What distinguishes starvation from deadlock?

    • A.Processes can wait forever without forming a circle
    • B.Memory is always accessible
    • C.The CPU is fully utilized
    • D.Processes are never blocked

    Why: Starvation occurs when a process waits indefinitely for resources because others are continuously prioritized, while deadlock involves processes waiting on each other in a circular manner.

  10. 10.Which of the following is NOT true about MST?

    • A.MST contains cycles
    • B.MST minimizes total weight
    • C.MST is unique if weights are distinct
    • D.MST has exactly V−1 edges

    Why: Minimum spanning trees (MST) cannot contain cycles, as they must connect all vertices with the minimum total weight without forming loops.

  11. 11.Segmentation simplifies the implementation of:

    • A.Page replacement
    • B.Contiguous allocation
    • C.Clustered allocation
    • D.Protection and sharing

    Why: Segmentation simplifies protection and sharing by allowing different segments of a program to have different access rights, facilitating better memory management.

  12. 12.What primarily causes file fragmentation?

    • A.Use of caching methods
    • B.Symbolic link usage
    • C.Hash table directories
    • D.Non-contiguous allocation of file segments

    Why: File fragmentation primarily occurs due to non-contiguous allocation of file segments, which leads to files being stored in scattered locations on the disk.

Practice all 2,994 Data Structures, Database, and Operating Systems questions

Adaptive mock tests, AI explanations on every question, and a personalized study plan.

Frequently asked questions

What is the average time complexity for hash table searches?
The average time complexity for hash table searches is O(1).
Which operation on a linked-list queue has a time complexity of O(1)?
The enqueue operation on a linked-list queue has a time complexity of O(1).
Which data structure is the best choice for priority scheduling tasks?
A priority queue is the best choice for priority scheduling tasks.
What methods can prevent deadlock?
Methods to prevent deadlock include resource allocation strategies, hold and wait prevention, and using timeouts.
Which sorting algorithm is both in-place and stable?
The Merge Sort algorithm is both in-place and stable.