Question

What are some important algorithms to know for computer science?

What are some important algorithms to know for computer science?

Homework Answers

Answer #1

`Hey,

Note: Brother if you have any queries related the answer please do comment. I would be very happy to resolve all your queries.

I am listing top 7

Here are the Top 7 algorithms and data structures to know:

  • Sort algorithms
  • Search algorithms
  • Hashing
  • Dynamic programming
  • Exponentiation by squaring
  • String matching and parsing
  • Primality testing algorithm

1. Sort Algorithms

Sorting is the most heavily studied concept in Computer Science. Idea is to arrange the items of a list in a specific order. Though every major programming language has built-in sorting libraries, it comes in handy if you know how they work. Depending on the requirement, you may want to use any of these.

  • Merge Sort
  • Quick Sort
  • Bucket Sort
  • Heap Sort
  • Counting Sort

2. Search Algorithms

Binary Search (in linear data structures) – Binary search is used to perform a very efficient search on sorted dataset. The time complexity is O(log2N). The idea is to repeatedly divide in half the portion of the list that could contain the item until we narrow it down to one possible item.

3. Hashing

Hash lookup is currently the most widely used technique to find appropriate data by key or ID. We access data by its index. Previously we relied on Sorting+Binary Search to look for index whereas now we use hashing.

The data structure is referred as Hash-Map or Hash-Table or Dictionary that maps keys to values, efficiently. We can perform value lookups using keys. Idea is to use an appropriate hash function which does the key -> value mapping. Choosing a good hash function depends on the scenario.

4. Dynamic Programming

Dynamic programming (DP) is a method for solving a complex problem by breaking it down into simpler subproblems. We solve the subproblems, remember their results and using them we make our way to solving the complex problem, quickly.

5. Exponentiation by squaring

Say you want to calculate 232. Normally we’d iterate 32 times and find the result. What if I told you it can be done in 5 iterations?

Exponentiation by squaring or Binary exponentiation is a general method for fast computation of large positive integer powers of a number in O(log2N). Not only this, the method is also used for computation of powers of polynomials and square matrices.

6. String Matching and Parsing

Pattern matching/searching is one of the most important problems in Computer Science. There have been a lot of research on the topic but we’ll enlist only two basic necessities for any programmer.

  • KMP Algorithm (String Matching)

Knuth-Morris-Pratt algorithm is used in cases where we have to match a short pattern in a long string. For instance, when we Ctrl+F a keyword in a document, we perform pattern matching in the whole document.

  • Regular Expression (String Parsing)

Many times we have to validate a string by parsing over a predefined restriction. It is heavily used in web development for URL parsing and matching.

7. Primality Testing Algorithms

There are deterministic and probabilistic ways of determining whether a given number is prime or not. We’ll see both deterministic and probabilistic (nondeterministic) ways.

  • Sieve of Eratosthenes (deterministic)

If we have a certain limit on the range of numbers, say determine all primes within range 100 to 1000 then Sieve is a way to go. The length of the range is a crucial factor because we have to allocate a certain amount of memory according to the range.

For any number n, incrementally testing up to sqrt(n) (deterministic)

In case you want to check for few numbers which are sparsely spread over a long range (say 1 to 1012), Sieve won’t be able to allocate enough memory. You can check for each number n by traversing only up to sqrt(n) and perform a divisibility check on n.

Kindly revert for any queries

Thanks.

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
What are some important things to know about the brain. Like its functions and what it's...
What are some important things to know about the brain. Like its functions and what it's made up of and things try to make it 250 words
What are the Applications of Matrices in Computer Science. Discuss at leat 4 applications.
What are the Applications of Matrices in Computer Science. Discuss at leat 4 applications.
80% of the employees in a specialized department of a large software firm are computer science...
80% of the employees in a specialized department of a large software firm are computer science graduates. A project team is made up of 9 employees. Part a) What is the probability to 3 decimal digits that all the project team members are computer science graduates? Part b) What is the probability to 3 decimal digits that exactly 3 of the project team members are computer science graduates? Part c) What is the most likely number of computer science graduates...
what are some of stuart firestein's ideas about science?
what are some of stuart firestein's ideas about science?
Indian Institute of Technology (IITs) delivers three courses: Mechanical Engineering, Electrical Engineering, and Computer Science. These...
Indian Institute of Technology (IITs) delivers three courses: Mechanical Engineering, Electrical Engineering, and Computer Science. These products have the following resources requirements: Course Cost/Unit Labour-Hours/Unit Mechanical Engineering $7.00 2 Electrical Engineering $10.00 3 Computer Science $35.00 5 IIT has a daily teaching budget of $5,000.00 and a maximum budget of 800 hours of labour. Selling prices are $15.00, $25.00 and $55.00 respectively. Maximum daily customer demand for Computer Science course is 100 units. The University desires to know the optimal...
This is artifical Intelligent class computer 1.List the typical search algorithms in each group. 2.For each...
This is artifical Intelligent class computer 1.List the typical search algorithms in each group. 2.For each typical search algorithm, list its properties and characteristics. 3.What is the "Perception-Action Problem"?
It has been determined that the mean amount of time that computer science majors spend on...
It has been determined that the mean amount of time that computer science majors spend on homework each week is approximately normally distributed with a mean of 15.2 hours and standard deviation 3.1 hours. What is the probability that a randomly selected computer science major will spend more than 14.5 hours on homework in a given week?
Why is it important to know that in some countries of this region (consider either North...
Why is it important to know that in some countries of this region (consider either North Africa or Southwest Asia or both) agriculture may produce only a small amount of the GDP yet employ 40 percent or more of the people? What are some of the things such a relationship would indicate about the state of development in that country? What public policies would be appropriate in these circumstances—for example, should agriculture be deemphasized? How might this deemphasis affect food...
Why is it important to study the history of Science and Technology?"
Why is it important to study the history of Science and Technology?"
There are 20 students in a class. 14 are computer science majors, 9 are math majors,...
There are 20 students in a class. 14 are computer science majors, 9 are math majors, and 4 are both. How many students from the class are neither computer science nor math majors? 3 1 6 0 Impossible to solve the problem.