Data Structures Midterm

Cards (33)

  • What is an Array List?
    A dynamic data structure built on top of an array.
  • How does resizing an Array List work?
    It creates a new underlying array and copies elements from the old one.
  • What must all elements in an Array List have in common?
    All elements must be the same data type.
  • What does the capacity of an Array List refer to?
    The maximum size of the underlying array.
  • What are some examples of List declarations in C#?
    • List<decimal> monies;
    • List<byte[]> buffers;
    • List<List<List<int>>>
  • What is the accuracy level of a Float data type?
    Close to accurate.
  • How accurate is a Double compared to a Float?
    Twice as accurate as floats.
  • When is the Decimal data type typically used?
    Often used for monetary values due to its high precision.
  • What is the syntax for a basic For Loop in C#?
    for(int i=0; i<10; i++) { Console.WriteLine(i); }
  • How can you modify a For Loop to step by 10?
    for(int i=0; i<10; i += 10) { Console.WriteLine(i); }
  • What is the purpose of a For Each Loop?
    It avoids off-by-one errors when iterating through a collection.
  • What is the basic operation of Bubble Sort?
    It compares an element with surrounding elements and moves the largest to the end.
  • What is the runtime complexity of Bubble Sort?
    O(n²)
  • How does Selection Sort operate?
    It finds the minimum element in the unsorted portion and swaps it with the first unsorted element.
  • What is the runtime complexity of Selection Sort?
    O(n²)
  • What does Insertion Sort do?
    It compares two elements and swaps them if they are not in order.
  • Why is Insertion Sort considered the fastest among simple iterative sorts for small n?
    It efficiently sorts elements by building a sorted array one element at a time.
  • How does Quick Sort function?
    It divides the array around a pivot and recursively sorts the sub-arrays.
  • What is the runtime complexity of Quick Sort?
    O(n log n)
  • How does Merge Sort operate?
    It divides the input array into two halves, sorts each half recursively, and merges them back together.
  • What is the runtime complexity of Merge Sort?
    O(n log n)
  • What are the types of testing in software development?
    • Unit Testing: Tests individual units (methods).
    • Integration Testing: Ensures compatibility between systems.
    • Performance Testing: Measures resource usage (CPU, memory, etc).
    • Acceptance Testing: Validates if the correct product was built.
  • What does LIFO stand for in the context of a Stack?
    Last In First Out.
  • What are the main operations of a Stack?
    Push, Pop, Peek.
  • What does FIFO stand for in the context of a Queue?
    First In First Out.
  • What are the main operations of a Queue?
    Enqueue, Dequeue, Peek.
  • What is a Deque?
    A hybrid of stack and queue.
  • What is a Singly Linked List?
    A linked list that contains a pointer to the next node.
  • What is a Doubly Linked List?
    A linked list that contains pointers to both next and previous nodes.
  • What is a Circular Linked List?
    A linked list where the last node points back to the head.
  • What is the structure of a Circular Node in C#?
    Class CircularNode<T> { Public T data; Public CircularNode next; Public CircularNode prev; }
  • How do you remove a node from a linked list?
    ToRemove.prev.next = ToRemove.next; ToRemove.next.prev = ToRemove.prev;
  • What are the key characteristics of linked lists?
    • Singly Linked: Pointer to next node.
    • Doubly Linked: Pointers to next and previous nodes.
    • Circular Linked List: Last node points back to the head.
    • Circular Doubly Linked List: Combines both features.