Topics In Demand
Notification
New

No notification found.

7 Data Structures and Algorithms Every Programmer Should Be Familiar With
7 Data Structures and Algorithms Every Programmer Should Be Familiar With

October 17, 2022

182

0

 

7 Data Structures and Algorithms Every Programmer Should Be Familiar With

 

If a programmer wants to build a successful career, data structures and algorithms are extremely important subjects to learn. With the help of the simplest examples, we shall see what they do and how they are used today. Modern development methods and competitive programming were considered when compiling this list.

  1. Sort Algorithms

Sorting has been the subject of the greatest computer science study. The aim is to arrange them in a specific order. Even though sorting libraries are included in many popular programming languages, it is still helpful to understand how they work. Depending on the circumstances, you could want to use any of them.

 

  • Merge Quick sorting, bucket sorting, heap sorting, and counting Sort
  • Understanding when and how to use them, though, is more important. Examples of circumstances when sorting techniques are directly applied include:
  • You may categorize items on e-commerce websites according to factors like popularity and price.

 

  1. Search Algorithms

 

  • Binary Lookup (in linear data structures)

Binary search is used to perform an incredibly efficient search on a sorted dataset. O is the time complexity (log2N). The objective is to divide the portion of the list that could contain the item in half repeatedly until there is only one possible item left. A few examples are:

When you search for a song title in a sorted list of song titles, binary search and string matching are employed to deliver the results quickly.

Used git bisects to debug git issues.

First Search: Depth and Breadth (in Graph data structures)

Data structures for finding and traversing trees and graphs include DFS and BFS. We won't get too deeply into how DFS and BFS operate, but the following animation will show how they differ.

 

  • Applications: Web crawling by search engines
  • Used to make artificially intelligent bots, such as chess bot
  • Finding the shortest path between two cities on a map is just one of many further uses of this kind.
  1. Hashing

Hash lookup is now the most used technique for finding pertinent data by key or ID. Data is accessed using its index. We now use hashing to find indexes rather than sorting and binary search as we initially did.

 

A data structure that effectively maps keys to values is known as a "Hash-Map," "Hash-Table," or "Dictionary." Using keys, we can look for values. The concept is to use a hash function, which converts keys into values. Choosing a suitable hash function should be based on the circumstances.

 

  • Applications: 
  • IP address storage and path pair for routing methods in routers
  • To ascertain whether a value is already present in a list. The cost of linear search would be high. The Set data structure is another option for this method.

 

  1. Dynamic Programming

Dynamic programming (DP) is a technique for decomposing a significant problem into smaller, more manageable challenges. We resolve the smaller issues, keep track of the solutions, and use those to tackle the larger, more complex issue quickly.

 

  • What does that equal? *writes "1+1+1+1+1+1+1+1 =" on a piece of paper*

Eight! (counts to eight) What about that? (adds another "1+" to the left)

*quickly

* Nine!

 

How did you quickly realize it was nine?

You recently added another.

You knew there were eight, so you didn't need to recount! Dynamic programming is just a fancy way of saying remembering things so you can save time later.

 

  • Applications:

There are various DP algorithms and uses, but the Duckworth-Lewis cricket method will blow you away.

  1. Exponentiation by squaring

Let's say you want to figure out 232. Normally, we would find the answer within 32 iterations. Would you believe me if I said that five iterations would be sufficient?

A typical technique for quickly computing large positive integer powers of a number in O is exponentiation by squaring, sometimes known as binary exponentiation (log2N). The method is also used to compute square matrices and polynomial powers.

 

  • Application: RSA encryption mostly calls for the computation of vast powers of a number. RSA makes use of both binary exponentiation and modular arithmetic.

 

  1. String Matching and Parsing

One of the fundamental problems in computer science is pattern matching and searching. Despite extensive research on the subject, we'll simply identify the top two requirements for programmers.

 

When we need to match a brief pattern within a lengthy string, we apply the Knuth-Morris-Pratt algorithm (KMP). For instance, pattern matching is carried out over the entire document when we Ctrl+F a keyword in a document.

We frequently need to validate a text by parsing it over a preset constraint using regular expressions (string parsing). In web development, it is often used for URL matching and parsing.

  1. Primality Testing Algorithms

It is possible to determine if a given number is prime using both deterministic and probabilistic methods.RSA makes use of both binary exponentiation and modular arithmetic.

 

  • The Eratosthenes Sieve (deterministic)

The Sieve is the way to go if we restrict the range of numbers, such as finding all primes between 100 and 1000. The length of the range is an essential consideration since we must allot a specific amount of memory based on the range.

gradually increasing the test to sqrt(n) for any value of n (deterministic)

 

If you want to check for a few widely scattered values across an extensive range (say 1 to 1012), Sieve won't be able to allocate adequate RAM. 

Hope this blog was informative for understanding DSA.

 

 


 


That the contents of third-party articles/blogs published here on the website, and the interpretation of all information in the article/blogs such as data, maps, numbers, opinions etc. displayed in the article/blogs and views or the opinions expressed within the content are solely of the author's; and do not reflect the opinions and beliefs of NASSCOM or its affiliates in any manner. NASSCOM does not take any liability w.r.t. content in any manner and will not be liable in any manner whatsoever for any kind of liability arising out of any act, error or omission. The contents of third-party article/blogs published, are provided solely as convenience; and the presence of these articles/blogs should not, under any circumstances, be considered as an endorsement of the contents by NASSCOM in any manner; and if you chose to access these articles/blogs , you do so at your own risk.


© Copyright nasscom. All Rights Reserved.