โ† All AMCAT Flashcard Decks

Computer Programming: Data Structures Flashcards

6 cards from real AMCAT practice questions. Tap to flip, then mark Knew It or Still Learning โ€” missed cards come back until you master them.

Read the first 6 Computer Programming: Data Structures flashcards as text
  1. A programmer needs to implement a system for a call center where calls are answered in the order they are received. Which data structure is the most appropriate for managing these incoming calls?

    Answer: Queue

    A Queue is the ideal data structure for this scenario because it follows the First-In, First-Out (FIFO) principle. This means the first call that comes in is the first one to be handled, perfectly modeling the 'first come, first served' requirement of the call center.

  2. In a scenario where you need to implement the 'undo' functionality in a text editor, which data structure would be most suitable for storing the sequence of operations?

    Answer: Stack

    A Stack is the best choice for an 'undo' feature. It operates on a Last-In, First-Out (LIFO) basis. The last action performed by the user is pushed onto the stack, and when 'undo' is clicked, that action is popped off the stack and reversed.

  3. Which of the following statements is true regarding the memory allocation for arrays and linked lists?

    Answer: Arrays require contiguous memory, while linked lists can have elements scattered in memory.

    Arrays are static data structures that require a block of contiguous memory locations to be allocated at compile time. In contrast, linked lists are dynamic; their nodes are allocated memory at runtime and can be located anywhere in memory, connected only by pointers.

  4. A developer is building a file system hierarchy for an operating system. Which non-linear data structure is the most appropriate to represent the relationship between directories and files?

    Answer: Tree

    A Tree is the perfect data structure for representing hierarchical relationships like a file system. A directory can contain other directories (sub-trees) and files (leaves), creating a clear parent-child structure that a tree model represents effectively.

  5. What is the primary advantage of using a hash table for searching for a specific element?

    Answer: It provides an average-case time complexity of O(1) for search operations.

    The main benefit of a hash table is its speed for search, insertion, and deletion operations. By using a hash function to map keys to indices in an array, it can achieve an average time complexity of O(1), making it extremely efficient for lookups.

  6. If you perform an in-order traversal on a Binary Search Tree (BST), in what order will the node values be visited?

    Answer: In ascending order

    A key property of a Binary Search Tree is that an in-order traversal (visiting the left subtree, then the root, then the right subtree) will always visit the nodes in ascending (sorted) order of their values.