- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 349 Articles for Data Structure Algorithms
5K+ Views
Stack is Last In First Out data structure. The stack is used in different area for evaluating expressions, call and recursion strategy etc. The stack has some primitive operations. Here we will see those operations of stack, and see one example using the stack ADT.The ADT (abstract datatype) is special kind of datatype, whose behavior is defined by a set of values and set of operations. The keyword “Abstract” is used as we can use these datatypes, we can perform different operations. But how those operations are working that is totally hidden from the user. The ADT is made of ... Read More
26K+ Views
The Data Type is basically a type of data that can be used in different computer program. It signifies the type like integer, float etc, the space like integer will take 4-bytes, character will take 1-byte of space etc.The abstract datatype is special kind of datatype, whose behavior is defined by a set of values and set of operations. The keyword “Abstract” is used as we can use these datatypes, we can perform different operations. But how those operations are working that is totally hidden from the user. The ADT is made of with primitive datatypes, but operation logics are ... Read More
67K+ Views
The reflected binary code or Gray code is an ordering of the binary numeral system such that two successive values differ in only one bit (binary digit). Gray codes are very useful in the normal sequence of binary numbers generated by the hardware that may cause an error or ambiguity during the transition from one number to the next. So, the Gray code can eliminate this problem easily since only one bit changes its value during any transition between two numbers.Conversion of Binary to Gray CodeGray codes are used in rotary and optical encoders, Karnaugh maps, and error detection. The ... Read More
307 Views
Fibonacci numbers are the numbers such that every number in the series after the first two is the sum of the two preceding ones. The series starts with 1, 1. Example −1, 1, 2, 3, 5, 8, 13, 21, 34, ….We can write a program to generate nth as follows −functionfibNaive(n) { if (n
2K+ Views
Dynamic programming breaks down the problem into smaller and yet smaller possible sub-problems. These sub-problems are not solved independently. Rather, results of these smaller sub-problems are remembered and used for similar or overlapping sub-problems. Dynamic programming is used where we have problems, which can be divided into similar sub-problems so that their results can be re-used. Mostly, these algorithms are used for optimization. Before solving the in-hand sub-problem, the dynamic algorithm will try to examine the results of the previously solved sub-problems. The solutions of sub-problems are combined in order to achieve the best solution. For a problem to be ... Read More
2K+ Views
Like the binary search, it also separates the lists into sub-lists. This procedure divides the list into three parts using two intermediate mid values. As the lists are divided into more subdivisions, so it reduces the time to search a key value.The complexity of Ternary Search TechniqueTime Complexity: O(log3 n)Space Complexity: O(1)Input and OutputInput: A sorted list of data: 12 25 48 52 67 79 88 93 The search key 52 Output: Item found at location: 3AlgorithmternarySearch(array, start, end, key)Input − An sorted array, start and end location, and the search keyOutput − location of the key (if found), otherwise wrong ... Read More
3K+ Views
Linear searching techniques are the simplest technique. In this technique, the items are searched one by one. This procedure is also applicable for unsorted data set. Linear search is also known as sequential search. It is named as linear because its time complexity is of the order of n O(n).The complexity of Linear Search TechniqueTime Complexity: O(n)Space Complexity: O(1)Input and OutputInput: A list of data: 20 4 89 75 10 23 45 69 the search key 10 Output: Item found at location: 4AlgorithmlinearSearch(array, size, key)Input − An sorted array, size of the array and the search keyOutput − location of the ... Read More
2K+ Views
For the binary search technique, the lists are divided into equal parts. For the interpolation searching technique, the procedure will try to locate the exact position using interpolation formula. After finding the estimated location, it can separate the list using that location. As it tries to find exact location every time, so the searching time reduces. This technique can find items easily if the items are uniformly distributed.The complexity of Interpolation Search TechniqueTime Complexity: O(log2(log2 n)) for the average case, and O(n) for the worst case (when items are distributed exponentially)Space Complexity: O(1)Input and OutputInput: A sorted list of data: ... Read More
3K+ Views
Exponential search is also known as doubling or galloping search. This mechanism is used to find the range where the search key may present. If L and U are the upper and lower bound of the list, then L and U both are the power of 2. For the last section, the U is the last position of the list. For that reason, it is known as exponential.After finding the specific range, it uses the binary search technique to find the exact location of the search key.The complexity of Exponential Search TechniqueTime Complexity: O(1) for the best case. O(log2 i) ... Read More