- 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 1862 Articles for Data Structure
![Alex Onsman](https://www.tutorialspoint.com/assets/profiles/13357/profile/60_91536-1512482971.jpg)
10K+ Views
Hashing is the process of generating a value from a text or a list of numbers using a mathematical function known as a hash function.There are many hash functions that use numeric numeric or alphanumeric keys. Different hash functions are given below:Hash FunctionsThe following are some of the Hash Functions −Division MethodThis is the easiest method to create a hash function. The hash function can be described as −h(k) = k mod nHere, h(k) is the hash value obtained by dividing the key value k by size of hash table n using the remainder. It is best that n is ... Read More
![Samual Sam](https://www.tutorialspoint.com/assets/profiles/13514/profile/60_83486-1512649303.jpg)
766 Views
Polynomial Time Approximation schemeWe can find some polynomial time solution for NP-Complete problems like 0-1 Knapsack problem or Subset sum problem. These problems are very popular in the real world, so there must be some ways to handle these problems.The Polynomial Time Approximation Scheme (PTAS) is a type to approximate algorithms for optimization problems. For the 0-1 Knapsack problem, there is a Pseudo Polynomial Solution, but when the values are large, the solution is not feasible. Then we need a PTAS solution.Some NP-complete problems like Graph Coloring, K-Center problem etc. they have no known polynomial time solution. PTAS used to approximate ... Read More
![Monica Mona](https://www.tutorialspoint.com/assets/profiles/13520/profile/60_87298-1512650151.jpg)
5K+ Views
Space ComplexitySpace complexity is an amount of memory used by the algorithm (including the input values of the algorithm), to execute it completely and produce the result.We know that to execute an algorithm it must be loaded in the main memory. The memory can be used in different forms:Variables (This includes the constant values and temporary values)Program InstructionExecutionAuxiliary SpaceAuxiliary space is extra space or temporary space used by the algorithms during its execution.Memory Usage during program executionInstruction Space is used to save compiled instruction in the memory.Environmental Stack is used to storing the addresses while a module calls another module ... Read More
![Ankith Reddy](https://www.tutorialspoint.com/assets/profiles/22328/profile/60_142162-1519038074.jpg)
15K+ Views
Amortize AnalysisThis analysis is used when the occasional operation is very slow, but most of the operations which are executing very frequently are faster. Data structures we need amortized analysis for Hash Tables, Disjoint Sets etc.In the Hash-table, the most of the time the searching time complexity is O(1), but sometimes it executes O(n) operations. When we want to search or insert an element in a hash table for most of the cases it is constant time taking the task, but when a collision occurs, it needs O(n) times operations for collision resolution.Aggregate MethodThe aggregate method is used to find ... Read More
![Samual Sam](https://www.tutorialspoint.com/assets/profiles/13514/profile/60_83486-1512649303.jpg)
26K+ Views
Asymptotic NotationsAsymptotic notations are used to represent the complexities of algorithms for asymptotic analysis. These notations are mathematical tools to represent the complexities. There are three notations that are commonly used.Big Oh NotationBig-Oh (O) notation gives an upper bound for a function f(n) to within a constant factor.We write f(n) = O(g(n)), If there are positive constantsn0 and c such that, to the right of n0 the f(n) always lies on or below c*g(n).O(g(n)) = { f(n) : There exist positive constant c and n0 such that 0 ≤ f(n) ≤ c g(n), for all n ≥ n0}Big Omega NotationBig-Omega ... Read More
![Monica Mona](https://www.tutorialspoint.com/assets/profiles/13520/profile/60_87298-1512650151.jpg)
35K+ Views
AlgorithmAn algorithm is a finite set of instructions, those if followed, accomplishes a particular task. It is not language specific, we can use any language and symbols to represent instructions.The criteria of an algorithmInput: Zero or more inputs are externally supplied to the algorithm.Output: At least one output is produced by an algorithm.Definiteness: Each instruction is clear and unambiguous.Finiteness: In an algorithm, it will be terminated after a finite number of steps for all different cases.Effectiveness: Each instruction must be very basic, so the purpose of those instructions must be very clear to us.Analysis of algorithmsAlgorithm analysis is an important part ... Read More
![Ankith Reddy](https://www.tutorialspoint.com/assets/profiles/22328/profile/60_142162-1519038074.jpg)
919 Views
This algorithm is used to print the array elements in a spiral way. At first starting from the first row, print the whole content and then follow the last column to print, then the last row and so on, thus it prints the elements in spiral fashion. The time complexity of this algorithm is O(MN), M is the number of rows and N is the number of columns.Input and OutputInput: The matrix: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 Output: Contents of ... Read More
![George John](https://www.tutorialspoint.com/assets/profiles/13511/profile/60_58410-1512537824.png)
454 Views
This algorithm will take an array and shuffle the contents of the array. It will generate a random permutation of the array elements.To solve this problem, we will swap elements starting from the last index to randomly generated an index in the array.Input and OutputInput: An array of integers: {1, 2, 3, 4, 5, 6, 7, 8} Output: Shuffle of array contents: 3 4 7 2 6 1 5 8 (Output may differ for next run)AlgorithmrandomArr(array, n)Input: The array, number of elements.Output: Shuffle the contents of the array.Begin for i := n – 1 down to 1, do ... Read More
![Samual Sam](https://www.tutorialspoint.com/assets/profiles/13514/profile/60_83486-1512649303.jpg)
5K+ Views
The magic square is a square matrix, whose order is odd and where the sum of the elements for each row or each column or each diagonal is same. The sum of each row or each column or each diagonal can be found using this formula. n(n2+ 1)/2Here are the rules to construct a magic square −We will start from the middle column of the first row, of the matrix, and always go to the top left corner to place next numberIf the row exceeds, or the row is not in the matrix, then, change the column as left column and ... Read More
![George John](https://www.tutorialspoint.com/assets/profiles/13511/profile/60_58410-1512537824.png)
4K+ Views
A list of given strings is sorted in alphanumeric order or Dictionary Order. Like for these words: Apple, Book, Aim, they will be sorted as Aim, Apple, Book.If there are some numbers, they can be placed before the alphabetic strings.Input and OutputInput: A list of strings: Ball Apple Data Area 517 April Man 506 Output: Strings after sort: 506 517 Apple April Area Ball Data ManAlgorithmsortStr(strArr, n)Input: The list of all strings, number of elements.Output − Strings in alphanumeric sorted order.Begin for round := 1 to n-1, do for i := 0 to n-round, do ... Read More