Home » CS201: Elementary Data Structures Certification Answers

CS201: Elementary Data Structures Certification Answers

by IndiaSuccessStories
0 comment

CS201: Elementary Data Structures Exam Quiz Answers

  • 0
  • 49
  • 50
  • 51
  • int my_array [3][4];
  • int my_array [4][3];
  • integer my_array [3][4];
  • int my_array [3], my_array [4];
  • Each abstract data type can have many definitions. Each is a definition instance.
  • An instance is the time taken to allocate memory for a defined abstract data type.
  • An abstract data type has a description or definition that is used to create instances.
  • Abstract data type definitions give instructions on each instance of memory allocation.
banner
  • Another name for a variable that holds the address of a block of memory
  • A floating-point number that specifies the address of an array’s first data value
  • The address of the first byte of a contiguous block of memory allocated by a program
  • The important information embedded in the assembler code generated by the compiler
  • int data [5][6];
  • std: array<std: array<int,5>,6> data;
  • int * data = (int*) malloc (5 * 6 * size of(int));
  • int * data [5]; for (int i = 0; i < 5; i++) data [i] = new int [6];
  • Push, Pop, Empty
  • Push, Sort, Retrieve
  • Add, Remove, Access
  • Insert, Access, Delete
  • Any entry is directly accessible.
  • Only the earliest entry is directly accessible.
  • Only the most recent entry is directly accessible.
  • Only the entry with the lowest value is accessible.
  • ABCD
  • ABDC
  • DBCA
  • DCBA
  • Only one pointer is used to keep track of the “front.”
  • Only one pointer is used to keep track of the “rear.”
  • Two pointers are used, one to track the “front” and the other to track the “rear.”
  • Two pointers are used, one for the next and the other for the previous queue elements.
  • Adding a new element to the rear of a queue.
  • Adding a new element to the front of a queue.
  • Removing an element from the front of a queue.
  • Computing the hash value of the element and inserting it in the queue.
  • 5
  • The memory address of the variable a
  • The memory address of the variable x
  • 0 or NULL (depending on the compiler), since the variable a contains a null pointer
  • *
  • ++
  • Both operators have the same precedence.
  • The syntax is incorrect, since pointer variables cannot be incremented.
  • Yes. Some compilers produce code for lesser bit lengths than the target computer.
  • Yes. The compiler makes decisions on variable numeric ranges based on memory availability.
  • No. Compilers for a given bit length do not produce executable code for different bit lengths.
  • No. The same code syntax is guaranteed to produce the same results regardless of compiler.
  • *
  • &
  • #
  • _
  • The variable a is equal to x.
  • The variable a is equal to 10.
  • The variable a points to the memory location of x.
  • This operation would corrupt the variable a, and should be avoided.
  • The character string g
  • The memory address of g
  • The character string galaxy
  • Nothing; the code will not compile since the syntax is incorrect
  • Scalar: C, Vector: R, Array: data[i]
  • Scalar: int[C], Vector: R, Array: data
  • Scalar: R, Vector: data, Array: int[C]
  • Scalar: R, Vector: data[i], Array: data
  • A constructor is required to contain input arguments.
  • A constructor automatically initializes all data members of a class.
  • A constructor is automatically invoked when a class is instantiated.
  • The name of the constructor is never the same as the name of the class.
  • It is wasted by the compiler.
  • It is available but not usable.
  • It is being used by another program.
  • It is allocated but never deallocated.
  • It is allocated at design time.
  • It is allocated at compile time.
  • It is allocated when an object is deleted.
  • It is used to dynamically allocate memory.
  • Foregoing the use of dynamically-allocated memory
  • Recasting memory pointers for use by other abstract data types
  • Ensuring there is a “delete” for every “new”, and a “free” for every “malloc” or “calloc”
  • Ensuring there is a “free” for every “new”, and a “delete” for every “malloc” or “calloc”
  • Struct declarations are the same in C and C++.
  • A compiler error results when public or private is not specified.
  • Class members are private and structure members are public by default.
  • Class members are public and structure members are private by default.
  • Hash Access
  • First-In/First-Out
  • Last-In/First-Out
  • Random Access
  • 1
  • 2
  • 3
  • 4
  • Adding a node
  • Deleting a node
  • Traversing a node
  • Direct random access to nodes
  • Singly linked list
  • Doubly linked list
  • Circular linked list
  • Hash-extension linked list
  • O (n)
  • O (log n)
  • O (n 2)
  • O (n log n)
  • O (n)
  • O (log n)
  • O (n 2)
  • O (n log n)
  • O (n)
  • O (log n)
  • O (n 2)
  • O (n log n)
  • O (n)
  • O (log n)
  • O (n 2)
  • O (n log n)
  • Bubble sort
  • Insertion sort
  • Merge sort
  • Selection Sort
  • O (1)
  • O (n)
  • O (log n)
  • O (n log n)
  • O (1)
  • O (n)
  • O (log n)
  • O (n log n)
  • Linear search is more efficient.
  • Binary search is more efficient.
  • Linear and binary search are equally efficient.
  • Either can be more efficient, depending on the type of data involved.
  • Bubble sort
  • Insertion sort
  • Merge sort
  • Selection sort
  • n2
  • n
  • n^2
  • log(n)+1
  • n=2(d+1)–1
  • Space efficiency is < n
  • The deepest node has depth < log n
  • Runtime efficiency is log n for all operations
  • At the end of the table
  • At the beginning of the table
  • At the key calculated by the function
  • Relative to the lowest-valued existing item
  • 0
  • 1
  • 2
  • 3
  • Arrays in contiguous memory
  • Linked lists in non-contiguous memory
  • A list to implement the hash table itself
  • A list to store entries with the same keys
  • Graphs are a special case of trees.
  • A graph must have at least one edge.
  • A graph must have at least one vertex.
  • Vertices are each connected via at least two edges.
  • Use real numbers
  • Allow table overflows
  • Use some random function
  • Map any key into one of the slots
  • n
  • n−1
  • 2n
  • log(n+1)/2
  • pre-order
  • post-order
  • depth-first
  • breadth-first
  • When two entries are identical except their keys
  • When two entries with different data have the same key
  • When two entries with the same key have different hash values
  • When two entries with different keys have the same hash value
  • Trails are a subset of walks.
  • Walks are a subset of circuits.
  • Paths are a super-set of walks.
  • Cycles are a super-set of walks.
  • 0
  • 1
  • 2
  • 3
  • Collisions never occur.
  • Sequential search looks for the key or its absence when a collision occurs.
  • Fibonacci steps are used to search for the key or its absence when a collision occurs.
  • A hash-function parameter is adjusted and the function is recalculated when a collision occurs.
  • O (1)
  • O (n)
  • O (log n)
  • O (n log n)
  • Any process having a pointer to the object can call any method within the object.
  • The memory occupied by the object itself and its internal data is entirely contiguous.
  • Structures contained within classes are not necessarily accessible outside the class object.
  • Their data is entirely public and can be changed by any process having a pointer to the object.
  • Garbage cleanup includes memory defragmentation.
  • The allocation method may employ blocks that point to sub-blocks.
  • Memory may be rearranged automatically by the operating system.
  • There may be insufficient memory to allocate the required block size.
  • Inserting
  • Popping
  • Pushing
  • Updating
  • Deleting
  • Popping
  • Pushing
  • Reallocating
  • Push, Pop
  • Insert, Delete
  • Inject, Extract
  • Enqueue, Dequeue
  • The memory address of the program’s main () function
  • A variable that stores the memory address of another variable
  • The memory address of the program’s last executable statement
  • The memory address of the program’s first executable statement
  • *
  • &
  • #
  • _
  • long int i;
  • double int i;
  • unsigned int i;
  • int i [<number of words desired>];
  • The value of the third element of the array is 8.
  • The value of the third element of the array is 10.
  • The pointer ptr1 contains the memory address of the first element of the array.
  • The pointer ptr1 contains the memory address of the third element of the array.
  • Does not point to any memory address
  • Holds the memory address of the main method
  • Points to a memory address that holds no value
  • Holds the memory address to the end of the program
  • At run time
  • At design time
  • At compile time
  • Only when a class constructor is invoked
  • To end a program
  • To release resources used by an object
  • To destroy viruses or malicious programs
  • To pass resources on to a replacement object
  • A data structure to store values in an array
  • A data structure that facilitates random access to stored values
  • A fixed-length data structure that expands and contracts as needed
  • A data structure where one value points to a subsequent and/or previous value
  • Hash Table
  • FIFO Queue
  • LIFO Queue
  • LILO Queue
  • O (n)
  • O (log n)
  • O (n2)
  • O (n log n)
  • O(n), O (log n), O (n2)
  • O (log n), O(n), O (n2)
  • O (n2), O(n), O (log n)
  • O (n2), O (log n), O(n)
  • O (1)
  • O (n)
  • O (log n)
  • O (n log n)
  • The first element in the array
  • The last element in the array
  • In the second half of the array
  • Somewhere in the middle of the array
  • 1
  • n
  • n+1/2
  • log(n)+1
  • O (n)
  • O (n2)
  • O (log n)
  • O (n log n)
  • O (1)
  • O (n)
  • O (log n)
  • O (n log n)
  • trail
  • critical path
  • spanning tree
  • multi-branch tree
  • n
  • n−1
  • n2
  • log(n+1)/2
  • h(i)=i
  • h(i)=i mod t
  • h(i)= (i
  • h(i)= (i mod(b/2)) −b
  • Paths are equivalent to trails.
  • Walks are a superset of trails.
  • Cycles are a subset of circuits.
  • Circuits are a superset of trails.
  • No cycles
  • Fewer edges
  • No spanning trees
  • Edges for traversal in one direction
  • 0
  • 1
  • 2
  • 3
  • Use chaining
  • Rebalance the table
  • Use a random hash function
  • Increase the size of the hash table
  • Memory blocks whose words all have consecutive addresses
  • Memory blocks that are allocated entirely from active memory
  • A collection of memory blocks where each block points to the next
  • A memory block that is allocated using standard language methods
  • The STL is a superset from which abstract data types are derived.
  • An ADT has a description or “definition”. STL members are not so constrained.
  • The STL is a collection of ADTs that offer definitions of commonly-required objects.
  • The STL is a library of ADTs created by the programmer over time to promote reusable code.
  • An infinite loop will occur.
  • The code will not compile.
  • At the end of the loop, the sum will be stored in the variable i.
  • At the end of the loop, the sum will be stored in the variable x.
  • Yes. Compilers have options that can be set for the bit-size of the computer in question.
  • Yes. The loader will always allocate appropriate memory and word lengths for the code in question.
  • No. The loader is not capable of allocating program space for code built for shorter word lengths.
  • No. Compilers for one bit-length will not produce executable code for computers of other bit-lengths.
  • A class cannot have more than one constructor.
  • A constructor without input arguments is not allowed.
  • A constructor with no arguments is called a default constructor.
  • A class without a default constructor will cause a compiler error.
  • Linked lists occupy contiguous memory.
  • Memory is allocated at the beginning of the program.
  • Memory is allocated dynamically as the program runs.
  • There are no nodes without programmer-assigned data values.
  • Singly linked lists
  • Doubly linked lists
  • Multiply linked lists
  • Circular linked lists
  • Array elements can be directly accessed, whereas linked list elements can only be accessed via an indexing vector.
  • Array elements always occupy contiguous memory, whereas linked lists always occupy non-contiguous memory.
  • Arrays use scalar index values to directly reference an element of the array. linked list elements do not have direct reference.
  • linked lists always include arrays as linked elements. These arrays provide pointers to subsequent and previous list elements.
  • It may contain loops.
  • It may have weighted edges.
  • It contains only undirected edges.
  • It has nodes that connect via multiple edges.
  • 0
  • 1
  • 2
  • 3
  • Slot 5
  • Slot 6
  • Slot 7
  • Slot 9
  • Trees can have cycles.
  • Trees are special cases of graphs.
  • Trees cannot be implemented using arrays.
  • Trees must be implemented using objects that point to each other.
  • 0
  • 1
  • 2
  • 3
  • Minimizes collisions
  • Minimizes insertion/deletion time
  • Produces a unique hash value for each different key
  • Produces a unique hash value in the least amount of time

Introduction to Elementary Data Structures

Elementary data structures are fundamental constructs in computer science that help in organizing, storing, and managing data efficiently. Understanding these structures is crucial because they form the foundation for more complex data structures and algorithms. Here’s a rundown of some of the basic data structures and their key properties:

1. Arrays

  • Description: An array is a collection of elements identified by index or key, all of which are of the same data type.
  • Characteristics:
    • Fixed size.
    • Elements are stored in contiguous memory locations.
    • Allows fast access via indexing (O(1) time complexity).
    • Insertions and deletions can be costly (O(n) time complexity) if the array needs to be resized or elements need to be shifted.

2. Linked Lists

  • Description: A linked list is a collection of nodes where each node contains a data element and a reference (or link) to the next node in the sequence.
  • Types:
    • Singly Linked List: Each node points to the next node.
    • Doubly Linked List: Each node points to both the next and the previous node.
    • Circular Linked List: The last node points back to the first node.
  • Characteristics:
    • Dynamic size.
    • Insertions and deletions are relatively easy and efficient (O(1) time complexity if you have a reference to the node).
    • Access time is linear (O(n) time complexity) because you have to traverse nodes sequentially.

3. Stacks

  • Description: A stack is a collection of elements that follows the Last In, First Out (LIFO) principle.
  • Operations:
    • Push: Add an element to the top.
    • Pop: Remove an element from the top.
    • Peek: View the element at the top without removing it.
  • Characteristics:
    • Implemented using arrays or linked lists.
    • Access to elements is only at the top.
    • Useful for problems involving recursion, parsing, and backtracking.

4. Queues

  • Description: A queue is a collection of elements that follows the First In, First Out (FIFO) principle.
  • Operations:
    • Enqueue: Add an element to the rear.
    • Dequeue: Remove an element from the front.
    • Peek: View the element at the front without removing it.
  • Characteristics:
    • Can be implemented using arrays or linked lists.
    • Useful for scheduling tasks, buffering, and handling asynchronous data.

5. Hash Tables

  • Description: A hash table is a data structure that maps keys to values using a hash function to compute an index into an array of buckets or slots.
  • Characteristics:
    • Provides fast access, insertion, and deletion (average O(1) time complexity).
    • Handles collisions using techniques like chaining (linked lists) or open addressing (probing).
    • Performance can degrade if the hash function isn’t well-designed or if the table becomes too full.

6. Trees

  • Description: A tree is a hierarchical data structure with a root node and children nodes forming a parent-child relationship.
  • Types:
    • Binary Tree: Each node has up to two children.
    • Binary Search Tree (BST): A binary tree where the left child is smaller and the right child is larger than the parent node.
    • AVL Tree: A self-balancing binary search tree.
    • Red-Black Tree: Another self-balancing binary search tree with additional properties to maintain balance.
  • Characteristics:
    • Allows hierarchical data representation and efficient searching, insertion, and deletion.
    • Operations depend on the type of tree and its balancing.

7. Heaps

  • Description: A heap is a special tree-based data structure that satisfies the heap property:
    • Min-Heap: The key at the root is the smallest among all keys in the heap.
    • Max-Heap: The key at the root is the largest among all keys in the heap.
  • Characteristics:
    • Used to implement priority queues.
    • Supports efficient access to the minimum or maximum element (O(1) time complexity) and insertion/deletion (O(log n) time complexity).

These data structures are building blocks for designing efficient algorithms and systems. Understanding their strengths and limitations helps in selecting the right structure for different problems and optimizing performance.

You may also like

Leave a Comment

Indian Success Stories Logo

Indian Success Stories is committed to inspiring the world’s visionary leaders who are driven to make a difference with their ground-breaking concepts, ventures, and viewpoints. Join together with us to match your business with a community that is unstoppable and working to improve everyone’s future.

Edtior's Picks

Latest Articles

Copyright © 2024 Indian Success Stories. All rights reserved.