Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update ReadMe with more info #141

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 74 additions & 2 deletions ReadMe.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,81 @@
# Introduction
This repository contains the pseudo-code of various algorithms and data structures necessary for **Interview Preparation** and **Competitive Coding**. The pseudocodes are written such that they can be easily adapted to any language. Let us remove the clutter of language and focus on the core concepts of the question!

* The questions in the project are NOT organized by difficulty. They are organized by question platform.

**Project includes questions from websites such as:**

* Codechef
* Codeforces
* Crash Course
* Crash Course ||
* E-Olymp
* GeekForGeeks
* HackerRank
* Leetcode


# Sample Pseudocode

**Sample 1:**
* **Algorithm** Find the maximum amount of water that can be trapped between the given bars
* **Ensure:** One Based Indexing for the array

```
1: function Trapping-Rain_Water (arr)
• left-max i represents the largest bar to the left of i (including it )
• right_maxli] represents the largest bar to the right of i (including it)
• contribution i denotes the maximum amount of water on top of the i - th bar

2: n <- arr.length

3: left_max[1] <- a[1]
4: for i = 2: n do
5: left_max[i] = max(left_max[i-1], a[i])

6: right_max[n] <- a[n]
7: for i = len - 1 down 1 do
8: right_max[i] = max(right_max[i+1], a[i])

9: for i = 1 : n do
10: max_height <- min(left_max[i],right_max[i])
11: contribution[i] <- (max_height - a[i])

12: total_water <- 0
13: for i = 1 : n do
14: total_water <- total_water + contribution[i]

15: return total_water
```

**Sample 2:**
* **Algorithm** Find the Median in a stream of integers

```
1: function MEDIAN_IN_STREAM(Stream)
• max heap contains elements smaller than or equal to median
• min heap contains elements bigger than or equal to median

• Insertion
2: for each element in stream do
3: max_heap.push(element)
4: max_element <- max_heap.top
5: max_heap.pop
6: min_heap.push(max_element)

• Balancing
7: if max_heap.size < min heap.size then
8: min_element <- min_heap.top
9: min_heap.pop
10: max_heap.push(min_element)

• Find Median
11: if max_heap.size == min_heap.size then
12: Print (max(max_heap) + min(min_heap))/2
13: else
14: Print max(max_heap)
```

# Sample GIF
![Images](Images/Sample.gif)

# Contribution
Read this section carefully if you are planning on contributing to this repository.
Expand Down