Insertion sort removes one element from the input data, finds the location it belongs within the sorted list, and inserts it there in each iteration. It repeats until no input elements remain. It always maintains a sorted sub list in the lower position of the list.
Time Complexity of this algorithm is O(n*n)
Insertion...
Tuesday, January 30, 2018
What is recursion?
Sometimes a problem is too difficult or too complex to solve because it is too big. If the problem can be broken down into smaller versions of itself, we may be able to find a way to solve one of these smaller versions and then be able to build up to a solution to the entire problem. This is...
undefined
201
A graph is a data structure which is a pictorial representation of a set of objects where pairs of objects are connected by links.
[problem]
Print the vertices that are adjacent to the given vertex in query.
[Input]
The first line contains the number of vertices V, the number of edges E and the number of queries Q.
From...
undefined
201
[problem]
Construct a tree with the given input and traverse the tree in preorder.
Then, print the visited node numbers.
[Input]
The first input line contains the number of total test cases, T.
The next line contains the number of total nodes, N and the number of edges, E.
On the following line, the edges will be given.
The...
undefined
201
Linked list is a linear collection of data elements pointing to the next node by means of a pointer.
It is a data structure consisting of a group of nodes which together represent a sequence.
[Problem]
Insert the given N integers to a linked list.
Print the remainder after
1. removing the first number pointed
2. removing...
undefined
201
A priority Queue is a data structure where each element has a "priority" associated with it.
In a priority queue, an element with high priority is served before an element with low priority.
[problem]
Store the given N (2 <= N <= 100) numbers into a priority queue, then print from the highest to the
lowest priority...
Tuesday, January 02, 2018
A hash table (hash map) is a data structure used to implement an associative array, a structure that can map keys to values.
Hash table uses a hash function to compute an index searching into an array of buckets or slots.
[problem]
Store the given N key and data pairs into a hash table, then print each data matching...