Written by students who passed Immediately available after payment Read online or as PDF Wrong document? Swap it for free 4.6 TrustPilot
logo-home
Class notes

data structure

Rating
-
Sold
-
Pages
24
Uploaded on
20-02-2025
Written in
2024/2025

best data structure notes

Institution
Course

Content preview

Tech Notes by Aftab Mahmood


Algorithms
hash tables, heaps, binary trees, linked lists, depth-first search, recursion, merge
●​ Divide and conquer Algorithm: works by recursively breaking down a problem into two or more sub
problems of the same (or related type) until these become simple enough to be solved directly. The
solution to sub-problems are then combined to give a solution to the original problem.
○​ Every algorithm that uses recursion or loops could be regarded as a divide-and-conquer
algorithm.
■​ quick sort, merge sort,
■​ binary search
■​ multiplying large numbers, Karatsuba
■​ syntactic analysis, top-down parsers
■​ discrete Fourier transform
○​ Divide and conquer typically splits the problem in half, solves each half, then stitches the halves
back together to form a full solution.
●​ Tail recursion or tail-end recursion is a special case of recursion in which last operation performed in a
recursive call.
○​ Return a (usually simple) value without recursion.
●​ Dynamic programming typically removes one element from the problem, solves the smaller problem,
and then uses the solution to this smaller problem to add back the element in the proper way.
○​ Dynamic programming is probably the easiest algorithm design technique to apply in practice.
●​ Greedy algorithms, which make the best local decision at each step




Analysis of Algorithms

Types of Analyses
●​ Best case - Running time determined by easiest input
●​ Worst case - Running time guarantee for all inputs
●​ Average case - Running time for random input


Commonly-used notations
●​ Tilde - provide approximate model
●​ Big Theta - classify algorithms
●​ Big Oh - develop upper bounds
●​ Big Omega - develop lower bounds




Map Reduce

,Big-O Notation:
1.​ Big-O notation provides an upper bound on the growth rate of the function.
2.​ Describes an algorithm’s usage of computational resources.
3.​ Expressed as a function of the length of its input using
4.​ O(N) describes an algorithm whose performance will linearly and in direct proportion to the
size of the input data set.
5.​ O(N^2) represents an algorithm whose performance is directly proportional to the square of
the size of the input data set.
6.​ If we have any input of size N, solving it will require at most f(N) steps.
●​ Bubble Sort O(n^2)
●​ Selection sort O(n^2)
●​ Quick Sort O(n^2)
●​ Heap Sort O(N log N)

●​ Big Theta is more tightly bound than Big O. mean there exists two constants c1 and c2 such
that c1n log n < f(n) < c2 log n
●​ Big Omega saya that the algorithen has a lower bound of c n log n
●​ Big O is not concerened with factors that do not chagne as the input increases.

●​ O(g) - asymptotic upper bound -
●​ omage Ω (g) - lower limit -
●​ theta θ(g) = O(g) ∩ Ω (g) - upper and lower bounds of a function are on the same order
of magnitude.
○​ A funciton is in big-theta of f if its not much worse but also not much better than f
●​ There is no asymptotic notation to describe the average case.
●​ dont congfure best / average /worst case with asymptotic bounds.

Issues:
1.​ Too hard to analyze
2.​ Average case unknown
3.​ Unknown constant: Big-O analysis only tells you how it grows with the size of the problem,
not now efficient it is. e.g. Both walking and travelling at the speed of light have a
time-as-function-of-distance of complexity O(N). Altho they have the same big-o
characteristics, one is faster than other.
4.​ Small data set

Estimating for recursive and nested loops
●​ estimate the maximum number of times each loop can be executed.
●​ add these bounds for cycles following each other.
●​ multiply theses founds for nested cycles/parts of code.
●​ Time complexity of a while cycle is O(n).

, References:
●​ http://www.topcoder.com/tc?module=Static&d1=tutorials&d2=complexity1




Sorting
Approaches to Sorting
●​ Selection of Data Structures
●​ Incremental Insertion Technique
○​ a particularly useful technique in geometric algorithms
●​ Divide and Conquer Technique
○​ Mergesort is a classic divide-and-conquer algorithm
●​ Randomization Technique
○​ In quicksort, we separate the n-1 other items into two piles: a low pile containing all the elements
that will appear before p in sorted order and a high pile containing all the elements that will appear
after p in sorted order. After sorting the two piles and arranging the piles correctly, we have
succeeded in sorting the n items.
●​ Bucketing Techniques
○​ Bucketing is a very effective idea whenever we are confident that the distribution of data will be
roughly uniform. It is the idea that underlies hash tables, kd-trees, and a variety of other
practical data structures. The downside of such techniques is that the performance can be
terrible whenever the data distribution is not what we expected.

Sorting methods:
●​ Insertion, selection, merge, exchange, partitioning
●​ in other words: Swap based, Merge based, Tree based
●​ cost of sorting - comparisons and exchanges

Stability:
●​ Stable sorting algorithms maintains the relative order of records with equal keys.
○​ one way of doing this to artificially extend the key comparision, so that comparisons between
two objects with othwerwise equal keys are decided using the order of the entries in the original
data order as a tie-breaker.
○​ (4, 2) (3, 7) (3, 1) (5, 6) can be sorted in two way
○​ (3, 7)..(3, 1)......
○​ (3, 1)..(3, 7).......

Written for

Institution
Course

Document information

Uploaded on
February 20, 2025
Number of pages
24
Written in
2024/2025
Type
Class notes
Professor(s)
Kk
Contains
All classes

Subjects

$10.99
Get access to the full document:

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Get to know the seller
Seller avatar
karanrathore

Get to know the seller

Seller avatar
karanrathore nit
Follow You need to be logged in order to follow users or courses
Sold
-
Member since
1 year
Number of followers
0
Documents
8
Last sold
-

0.0

0 reviews

5
0
4
0
3
0
2
0
1
0

Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions