DSAlg - Midterm Reviewer - BSINFOTECH-2B

    Master this deck with 47 terms through effective study methods.

    Generated from uploaded pdf

    Created by @ashle

    What is a data structure?

    A specialized format for organizing and storing data.

    What does an algorithm combined with a data structure create?

    A program.

    What is the representation of a data structure in main memory called?

    Storage structure.

    What is the representation of a data structure in auxiliary memory called?

    File structure.

    What are the four things a data structure specifies?

    Organization of data, accessing method, degree of associativity, processing alternative.

    What are the two main types of data structures?

    Primitive and non-primitive.

    What are the four primitive data types?

    Integer, float, character, pointer.

    What does a pointer hold?

    The memory address of another variable.

    What are examples of non-primitive data structures?

    Array, list, and file.

    How can a linear structure be represented in memory?

    Static and dynamic memory allocation.

    What are the insertion and deletion operations for a stack?

    PUSH for insertion, POP for deletion.

    Which end of a queue deletes and which end inserts?

    FRONT deletes, REAR inserts.

    What are two examples of non-linear data structures?

    Tree and graph.

    How can a tree be viewed?

    As a restricted graph.

    What operation combines two sorted lists into one?

    Merging.

    What operation visits each node of a list systematically?

    Traversing.

    What does each array element have?

    A value and an index.

    What are the valid indexes of an array of size n?

    0 to n − 1.

    What does arrayName[indexNum] do?

    Accesses the element at that index.

    What is the difference between static and dynamic array initialization?

    Static: values at declaration; dynamic: values at execution.

    What does a negative index return?

    A garbage value.

    What is the syntax of a 2D array?

    data-type arrayName[row][col].

    What are the three kinds of arrays?

    One-dimensional, two-dimensional, multidimensional.

    What is a linked list?

    A linear collection of nodes where each node points to the next.

    What are the two parts of a node in a linked list?

    Data and next.

    What does the head pointer refer to in a linked list?

    The first node.

    What does the last node in a linked list point to?

    NULL.

    How does access by index differ between arrays and linked lists?

    Array O(1); linked list O(n) due to traversal.

    What are the three types of linked lists?

    Singly, doubly, circular.

    Which linked list has both prev and next pointers?

    Doubly linked list.

    In a circular linked list, where does the last node point?

    Back to the head.

    What is the time complexity of traversal in a linked list?

    O(n).

    What is the time complexity to insert at the head of a linked list?

    O(1).

    When inserting after a node, which pointer should be set first?

    The new node's next pointer.

    How do you delete a node in a singly linked list?

    Make the previous node skip over it.

    What are the edge cases of deletion in a linked list?

    Deleting the head, an empty list, value not found.

    Why is the remove function not named delete?

    Delete is a C++ keyword.

    Why do we need a destructor in C++ for linked lists?

    To prevent memory leaks.

    What is the cost of append with only a head pointer?

    O(n).

    How many comparisons does search(8) make on 3→7→8→9?

    3 comparisons.

    What does reverse() do in a linked list?

    Flips the next pointers to reverse the list.

    How does the slow/fast pointer method find the middle of a linked list?

    Fast moves two nodes per round, slow moves one.

    What does middle() return for 1→2→3→4?

    3 (the second middle).

    Which list type is best for browser back/forward navigation?

    Doubly linked list.

    What are two advantages of linked lists?

    Dynamic size and fast insert/delete.

    What are two disadvantages of linked lists?

    No random access and pointer overhead.

    Name some real uses of linked lists.

    Music playlists, browser history, undo/redo.


      DSAlg - Midterm Reviewer - BSINFOTECH-2B Study Notes | Cramd