CSC 202 Midterm Exam
Priori Analysis
This is a theoretical analysis of an algorithm. Efficiency of an algorithm is measured by assuming that all other factors are constant.
What are some basic operations supported by arrays?
1. Traverse 2. Insertion 3. Deletion 4. Search 5. Update
Space complexity of an algorithm
It represents the amount of memory space required by the algorithm in its life cycle.
Time complexity of an algorithm
It represents the amount of time required by the algorithm to run to completion.
Node
It stores a data item called an element and a link to the next Node.
Simple Linked List
Item navigation is forward only.
Doubly Linked List
Items can be navigated forward and backward.
What are the operations that can be performed by the data structures?
1. Traversing 2. Searching 3. Insertion 4. Deletion 5. Sorting 6. Merging
What are the limitations of arrays?
- The size of the arrays is fixed - Inserting a new element in an array of elements is expensive - Deletion is also expensive
What are the advantages of DLL over singly linked list?
-A DLL can be traversed in both forward and backward direction. - The delete operation in DLL is more efficient if pointer to the node to be deleted is given.
What are the two data types?
1. Built-in Data Type 2. Derived Data Type
What are the characteristics of a data structure?
1. Correctness 2. Time Complexity 3. Space Complexity
What are the advantages of a circular linked list?
- Any node can be a starting point. -Useful for implementation of queue. - useful in applications to repeatedly go around the list. - used for implementation of advanced data structures like Fibonacci Heap
What are the advantages of a linked list over an array?
- Dynamic size - Ease of insertion/deletion
What are the disadvantages of DLL over singly linked list?
- Every node of DLL Require extra space for an previous pointer. It is possible to implement DLL with single pointer though . - All operations require an extra pointer previous to be maintained. For example, in insertion, we need to modify previous pointers together with next pointers.
What are the drawbacks of a linked list?
- Random access is not allowed. -Extra memory space for a pointer is required with each element of the list.
Record
A collection of field values of a given entity. (One row of details about an entity)
Field
A single elementary unit of information representing an attribute of an entity. (Columns used to capture attributes)
Algorithm
A step-by-step procedure to execute a set of instructions in a certain order
Data Structure
A systematic way to organize data in order to use it efficiently.
File
Collection of records of the entities in a given entity set.
What are the three common problems that applications face now-a-days?
Data Search, Processor speed, Multiple requests
Group Items
Data items that can be divided into sub items. e.g. Name: First Name, Middle initial and Last Name
Elementary Items
Data items that cannot be divided into sub item. Ex : PAN card number / Bank Pass Book Number
Correctness
Data structure implementation should implement its interface correctly.
Attribute
Details about the entity
Prev
Each link of a linked list contains a link to the previous link. (Double Linked list)
What are the foundation terms of a data structure?
Interface & Implementation
Next
It contains a link to the next link called Next.
Entity
It contains certain attributes which may be assigned values.
Head Node
It contains the connection link to the first Node.
The complexity of an algorithm
It gives the running time and the storage space required by the algorithm in terms of the size of input data.
Array
It is a container which can hold a fix number of items and these items should be of the same type.
Linked list
It is a sequence of data structures which are connected together via links. It is sequence of nodes.
Variable part
It is a space required by variables, whose size depends on the size of the problem.
Fixed part
It is a space required to store certain data and variables, that are independent of the size of the problem.
Entity Set
It is formed by entities of similar attributes
Data Object
It represents an object having a data.
Circular Linked List
Last item contains link of the first element as next and the first element has a link to the last element as previous.
Space Complexity
Memory usage of a data structure operation should be as little as possible.
Traverse
Print all the array elements one by one.
What are the two ways of measuring the efficiency of an algorithm?
Priori Analysis, Posterior Analysis
Time Complexity
Running time or the execution time of operations of data structure must be as small as possible.
S(P) of any algorithm P
S(P) = C + S(I)
What are the categories of algorithm?
Search, Sort, Insert, Update, Delete
Space Factor
Space is measured by counting the maximum memory space required by the algorithm
T(n)
T(n) = c ∗ n
Implementation
The internal representation of a data structure. It also provides definition of the algorithms used in the operations of the data structure
Interface
The set of operations that a data structure supports
Execution Time Cases
This are cases which are usually used to compare various data structure's execution time in a relative manner.
Posterior Analysis
This is an empirical analysis of an algorithm. The selected algorithm is implemented using programming language, executed on target computer machine and statistics are collected.
Average Case
This is the scenario showing the average execution time of an operation of a data structure.
Best Case
This is the scenario showing the least possible execution time of an operation of a data structure.
Worst Case
This is the scenario where a particular data structure operation takes maximum time it can take.
Built-in Data types
Those data types for which a language has built-in support. i.e. - Integers - Boolean (true, false) - Floating (Decimal numbers) - Character and Strings
Derived Data types
Those data types which are implementation independent as they can be implemented in one or the other way. i.e. - List - Array - Stack - Queue
Time Factor
Time is measured by counting the number of key operations in an algorithm.
What are the characteristics of an algorithm?
Unambiguous, Input, Output, Finiteness, Feasibility, Independent
What are the three execution time cases?
Worst Case, Average Case, Best Case
Data
set of values
Data Item
single unit of values.
Which are the two main factors which decide the efficiency of an algorithm?
time and space factor