Data Structures and Algorithms in Real Life examples
Array :
2D arrays (matrices) are mainly used in Image Processing.
RGB image uses a 3D matrix.
2D arrays are also used in Game Design like Sudoku, Chess.
The Leader Board of game or coding contest.
Stack :
Used in backtracking, check valid parenthesis in an expression.
Evaluating Infix and Postfix expressions.
Used in Recursive function calls to store function calls and their results.
Undo and Redo operations in word processors like MS-Word, and Notepad.
Browsing history of visited websites.
Call history/log in mobile phones.
Java Virtual Machine uses a stack to store immediate calculation results.
Queue:
Windows operating system uses a circular queue to switch between different applications.
Used in First Come First Serve job/CPU scheduling algorithm which follows FIFO order.
All the requests are queued for the server to respond.
Priority Queue :
A priority queue is used in priority scheduling algorithm and interrupt handling in OS.
Used in Huffman Coding in compression algorithms.
Linked List:
Previous and Next Page in Web Browser.
Songs in the music player are linked to the previous and next songs using doubly linked list.
Next and previous images in a phone gallery.
Multiple Applications running on a PC uses circular linked list.
Used for the implementation of stacks, queues, trees, and graphs.
Graph :
In Facebook, LinkedIn and other social networking sites, users are considered to be the vertices and the edge between them indicates that they are connected.
Facebookβs Graph API and Googleβs Knowledge API are the best examples of grpah.
Google Maps, Yahoo Maps, Apple Maps uses graph to show the shortest path using Breadth First Search (BFS).
Used in HTML DOM and React Virtual DOM.
Tree :
Representation structure in File Explorer. (Folders and Subfolders) uses N-ary Tree.
Auto-suggestions when you google something using Trie.
Used in decision-based machine learning algorithms.
Used in Backtracking to maintain the state-space tree.
A binary tree is used in database indexing to store and retrieve data in an efficient manner.
To implement Heap data structure.
Binary Search Trees: (BST) can be used in sorting algorithms.
Dijkstra Algorithm :
This algorithm is used to find the shortest path between two vertices in a graph in such a way that the sum of weights between the edges is minimum.
Prims Algorithm :
It is a greedy algorithm to obtain a minimum spanning tree.
Array :
2D arrays (matrices) are mainly used in Image Processing.
RGB image uses a 3D matrix.
2D arrays are also used in Game Design like Sudoku, Chess.
The Leader Board of game or coding contest.
Stack :
Used in backtracking, check valid parenthesis in an expression.
Evaluating Infix and Postfix expressions.
Used in Recursive function calls to store function calls and their results.
Undo and Redo operations in word processors like MS-Word, and Notepad.
Browsing history of visited websites.
Call history/log in mobile phones.
Java Virtual Machine uses a stack to store immediate calculation results.
Queue:
Windows operating system uses a circular queue to switch between different applications.
Used in First Come First Serve job/CPU scheduling algorithm which follows FIFO order.
All the requests are queued for the server to respond.
Priority Queue :
A priority queue is used in priority scheduling algorithm and interrupt handling in OS.
Used in Huffman Coding in compression algorithms.
Linked List:
Previous and Next Page in Web Browser.
Songs in the music player are linked to the previous and next songs using doubly linked list.
Next and previous images in a phone gallery.
Multiple Applications running on a PC uses circular linked list.
Used for the implementation of stacks, queues, trees, and graphs.
Graph :
In Facebook, LinkedIn and other social networking sites, users are considered to be the vertices and the edge between them indicates that they are connected.
Facebookβs Graph API and Googleβs Knowledge API are the best examples of grpah.
Google Maps, Yahoo Maps, Apple Maps uses graph to show the shortest path using Breadth First Search (BFS).
Used in HTML DOM and React Virtual DOM.
Tree :
Representation structure in File Explorer. (Folders and Subfolders) uses N-ary Tree.
Auto-suggestions when you google something using Trie.
Used in decision-based machine learning algorithms.
Used in Backtracking to maintain the state-space tree.
A binary tree is used in database indexing to store and retrieve data in an efficient manner.
To implement Heap data structure.
Binary Search Trees: (BST) can be used in sorting algorithms.
Dijkstra Algorithm :
This algorithm is used to find the shortest path between two vertices in a graph in such a way that the sum of weights between the edges is minimum.
Prims Algorithm :
It is a greedy algorithm to obtain a minimum spanning tree.
π6β€1
Easy Python scenarios for everyday data tasks
Scenario 1: Data Cleaning
Question:
You have a DataFrame containing product prices with columns Product and Price. Some of the prices are stored as strings with a dollar sign, like $10. Write a Python function to convert the prices to float.
Answer:
import pandas as pd
data = {
'Product': ['A', 'B', 'C', 'D'],
'Price': ['$10', '$20', '$30', '$40']
}
df = pd.DataFrame(data)
def clean_prices(df):
df['Price'] = df['Price'].str.replace('$', '').astype(float)
return df
cleaned_df = clean_prices(df)
print(cleaned_df)
Scenario 2: Basic Aggregation
Question:
You have a DataFrame containing sales data with columns Region and Sales. Write a Python function to calculate the total sales for each region.
Answer:
import pandas as pd
data = {
'Region': ['North', 'South', 'East', 'West', 'North', 'South', 'East', 'West'],
'Sales': [100, 200, 150, 250, 300, 100, 200, 150]
}
df = pd.DataFrame(data)
def total_sales_per_region(df):
total_sales = df.groupby('Region')['Sales'].sum().reset_index()
return total_sales
total_sales = total_sales_per_region(df)
print(total_sales)
Scenario 3: Filtering Data
Question:
You have a DataFrame containing customer data with columns βCustomerIDβ, Name, and Age. Write a Python function to filter out customers who are younger than 18 years old.
Answer:
import pandas as pd
data = {
'CustomerID': [1, 2, 3, 4, 5],
'Name': ['Alice', 'Bob', 'Charlie', 'David', 'Eve'],
'Age': [17, 22, 15, 35, 40]
}
df = pd.DataFrame(data)
def filter_customers(df):
filtered_df = df[df['Age'] >= 18]
return filtered_df
filtered_customers = filter_customers(df)
print(filtered_customers)
Scenario 1: Data Cleaning
Question:
You have a DataFrame containing product prices with columns Product and Price. Some of the prices are stored as strings with a dollar sign, like $10. Write a Python function to convert the prices to float.
Answer:
import pandas as pd
data = {
'Product': ['A', 'B', 'C', 'D'],
'Price': ['$10', '$20', '$30', '$40']
}
df = pd.DataFrame(data)
def clean_prices(df):
df['Price'] = df['Price'].str.replace('$', '').astype(float)
return df
cleaned_df = clean_prices(df)
print(cleaned_df)
Scenario 2: Basic Aggregation
Question:
You have a DataFrame containing sales data with columns Region and Sales. Write a Python function to calculate the total sales for each region.
Answer:
import pandas as pd
data = {
'Region': ['North', 'South', 'East', 'West', 'North', 'South', 'East', 'West'],
'Sales': [100, 200, 150, 250, 300, 100, 200, 150]
}
df = pd.DataFrame(data)
def total_sales_per_region(df):
total_sales = df.groupby('Region')['Sales'].sum().reset_index()
return total_sales
total_sales = total_sales_per_region(df)
print(total_sales)
Scenario 3: Filtering Data
Question:
You have a DataFrame containing customer data with columns βCustomerIDβ, Name, and Age. Write a Python function to filter out customers who are younger than 18 years old.
Answer:
import pandas as pd
data = {
'CustomerID': [1, 2, 3, 4, 5],
'Name': ['Alice', 'Bob', 'Charlie', 'David', 'Eve'],
'Age': [17, 22, 15, 35, 40]
}
df = pd.DataFrame(data)
def filter_customers(df):
filtered_df = df[df['Age'] >= 18]
return filtered_df
filtered_customers = filter_customers(df)
print(filtered_customers)
π1
Top 9 websites for practicing algorithms and Data structure.
β https://www.hackerrank.com/
β https://leetcode.com/
β https://www.codewars.com/
β https://www.hackerearth.com/for-developers
β https://coderbyte.com/
β https://www.coursera.org/browse/computer-science/algorithms
β https://www.codechef.com/
β https://codeforces.com/
β https://www.geeksforgeeks.org/
β https://www.hackerrank.com/
β https://leetcode.com/
β https://www.codewars.com/
β https://www.hackerearth.com/for-developers
β https://coderbyte.com/
β https://www.coursera.org/browse/computer-science/algorithms
β https://www.codechef.com/
β https://codeforces.com/
β https://www.geeksforgeeks.org/
π2β€1
Essential Tools & Programming Languages for Software Developers
π Integrated Development Environments (IDEs):
- Visual Studio Code: A lightweight but powerful source code editor that supports various programming languages and extensions.
- IntelliJ IDEA: A popular IDE for Java development, also supporting other languages through plugins.
- Eclipse: Another widely used IDE for Java, with extensive plugin support for other languages.
π Version Control Systems:
- Git: A distributed version control system that allows developers to track changes in their codebase, collaborate with others, and manage project history. GitHub, GitLab, and Bitbucket are popular platforms that use Git.
π Programming Languages:
- JavaScript: Essential for web development, with frameworks like React, Angular, and Vue.js for front-end development and Node.js for server-side programming.
- Python: Known for its simplicity and versatility, used in web development (Django, Flask), data science (NumPy, Pandas), and automation.
- Java: Widely used for building enterprise-scale applications, Android app development, and backend systems.
- C#: A language developed by Microsoft, primarily used for building Windows applications and games using the Unity engine.
- C++: Known for its performance, used in system/software development, game development, and applications requiring real-time processing.
- Ruby: Known for its simplicity and productivity, often used in web development with the Ruby on Rails framework.
π Web Development Frameworks:
- React: A JavaScript library for building user interfaces, particularly single-page applications.
- Angular: A TypeScript-based framework for building dynamic web applications.
- Django: A high-level Python web framework that encourages rapid development and clean, pragmatic design.
- Spring: A comprehensive framework for Java that provides infrastructure support for developing Java applications.
π Database Management Systems:
- MySQL: An open-source relational database management system.
- PostgreSQL: An open-source object-relational database system with a strong emphasis on extensibility and standards compliance.
- MongoDB: A NoSQL database that uses a flexible, JSON-like format for storing data.
π Containerization and Orchestration:
- Docker: A platform that allows developers to package applications into containers, ensuring consistency across multiple environments.
- Kubernetes: An open-source system for automating deployment, scaling, and management of containerized applications.
π Cloud Platforms:
- Amazon Web Services (AWS): A comprehensive cloud platform offering a wide range of services, including computing power, storage, and databases.
- Microsoft Azure: A cloud computing service created by Microsoft for building, testing, deploying, and managing applications.
- Google Cloud Platform (GCP): A suite of cloud computing services provided by Google.
π CI/CD Tools:
- Jenkins: An open-source automation server that helps automate the parts of software development related to building, testing, and deploying.
- Travis CI: A continuous integration service used to build and test software projects hosted on GitHub.
π Project Management and Collaboration:
- Jira: A tool developed by Atlassian for bug tracking, issue tracking, and project management.
- Trello: A visual tool for organizing tasks and projects into boards.
Programming & Data Analytics Resources: https://t.me/free4unow_backup/796
Best Programming Resources: https://topmate.io/coding/886839
Join @free4unow_backup for more free courses
Like for more β€οΈ
ENJOY LEARNINGππ
π Integrated Development Environments (IDEs):
- Visual Studio Code: A lightweight but powerful source code editor that supports various programming languages and extensions.
- IntelliJ IDEA: A popular IDE for Java development, also supporting other languages through plugins.
- Eclipse: Another widely used IDE for Java, with extensive plugin support for other languages.
π Version Control Systems:
- Git: A distributed version control system that allows developers to track changes in their codebase, collaborate with others, and manage project history. GitHub, GitLab, and Bitbucket are popular platforms that use Git.
π Programming Languages:
- JavaScript: Essential for web development, with frameworks like React, Angular, and Vue.js for front-end development and Node.js for server-side programming.
- Python: Known for its simplicity and versatility, used in web development (Django, Flask), data science (NumPy, Pandas), and automation.
- Java: Widely used for building enterprise-scale applications, Android app development, and backend systems.
- C#: A language developed by Microsoft, primarily used for building Windows applications and games using the Unity engine.
- C++: Known for its performance, used in system/software development, game development, and applications requiring real-time processing.
- Ruby: Known for its simplicity and productivity, often used in web development with the Ruby on Rails framework.
π Web Development Frameworks:
- React: A JavaScript library for building user interfaces, particularly single-page applications.
- Angular: A TypeScript-based framework for building dynamic web applications.
- Django: A high-level Python web framework that encourages rapid development and clean, pragmatic design.
- Spring: A comprehensive framework for Java that provides infrastructure support for developing Java applications.
π Database Management Systems:
- MySQL: An open-source relational database management system.
- PostgreSQL: An open-source object-relational database system with a strong emphasis on extensibility and standards compliance.
- MongoDB: A NoSQL database that uses a flexible, JSON-like format for storing data.
π Containerization and Orchestration:
- Docker: A platform that allows developers to package applications into containers, ensuring consistency across multiple environments.
- Kubernetes: An open-source system for automating deployment, scaling, and management of containerized applications.
π Cloud Platforms:
- Amazon Web Services (AWS): A comprehensive cloud platform offering a wide range of services, including computing power, storage, and databases.
- Microsoft Azure: A cloud computing service created by Microsoft for building, testing, deploying, and managing applications.
- Google Cloud Platform (GCP): A suite of cloud computing services provided by Google.
π CI/CD Tools:
- Jenkins: An open-source automation server that helps automate the parts of software development related to building, testing, and deploying.
- Travis CI: A continuous integration service used to build and test software projects hosted on GitHub.
π Project Management and Collaboration:
- Jira: A tool developed by Atlassian for bug tracking, issue tracking, and project management.
- Trello: A visual tool for organizing tasks and projects into boards.
Programming & Data Analytics Resources: https://t.me/free4unow_backup/796
Best Programming Resources: https://topmate.io/coding/886839
Join @free4unow_backup for more free courses
Like for more β€οΈ
ENJOY LEARNINGππ
π8
Β©How fresher can get a job as a data scientist?Β©
Job market is highly resistant to hire data scientist as a fresher. Everyone out there asks for at least 2 years of experience, but then the question is where will we get the two years experience from?
The important thing here to build a portfolio. As you are a fresher I would assume you had learnt data science through online courses. They only teach you the basics, the analytical skills required to clean the data and apply machine learning algorithms to them comes only from practice.
Do some real-world data science projects, participate in Kaggle competition. kaggle provides data sets for practice as well. Whatever projects you do, create a GitHub repository for it. Place all your projects there so when a recruiter is looking at your profile they know you have hands-on practice and do know the basics. This will take you a long way.
All the major data science jobs for freshers will only be available through off-campus interviews.
Some companies that hires data scientists are:
Siemens
Accenture
IBM
Cerner
Creating a technical portfolio will showcase the knowledge you have already gained and that is essential while you got out there as a fresher and try to find a data scientist job.
Job market is highly resistant to hire data scientist as a fresher. Everyone out there asks for at least 2 years of experience, but then the question is where will we get the two years experience from?
The important thing here to build a portfolio. As you are a fresher I would assume you had learnt data science through online courses. They only teach you the basics, the analytical skills required to clean the data and apply machine learning algorithms to them comes only from practice.
Do some real-world data science projects, participate in Kaggle competition. kaggle provides data sets for practice as well. Whatever projects you do, create a GitHub repository for it. Place all your projects there so when a recruiter is looking at your profile they know you have hands-on practice and do know the basics. This will take you a long way.
All the major data science jobs for freshers will only be available through off-campus interviews.
Some companies that hires data scientists are:
Siemens
Accenture
IBM
Cerner
Creating a technical portfolio will showcase the knowledge you have already gained and that is essential while you got out there as a fresher and try to find a data scientist job.
π3
β
Meta interview questions : Most asked in last 30 days
1. 1249. Minimum Remove to Make Valid Parentheses
2. 408. Valid Word Abbreviation
3. 215. Kth Largest Element in an Array
4. 314. Binary Tree Vertical Order Traversal
5. 88. Merge Sorted Array
6. 339. Nested List Weight Sum
7. 680. Valid Palindrome II
8. 973. K Closest Points to Origin
9. 1650. Lowest Common Ancestor of a Binary Tree III
10. 1. Two Sum
11. 791. Custom Sort String
12. 56. Merge Intervals
13. 528. Random Pick with Weight
14. 1570. Dot Product of Two Sparse Vectors
15. 50. Pow(x, n)
16. 65. Valid Number
17. 227. Basic Calculator II
18. 560. Subarray Sum Equals K
19. 71. Simplify Path
20. 200. Number of Islands
21. 236. Lowest Common Ancestor of a Binary Tree
22. 347. Top K Frequent Elements
23. 498. Diagonal Traverse
24. 543. Diameter of Binary Tree
25. 1768. Merge Strings Alternately
26. 2. Add Two Numbers
27. 4. Median of Two Sorted Arrays
28. 7. Reverse Integer
29. 31. Next Permutation
30. 34. Find First and Last Position of Element in Sorted Array
31. 84. Largest Rectangle in Histogram
32. 146. LRU Cache
33. 162. Find Peak Element
34. 199. Binary Tree Right Side View
35. 938. Range Sum of BST
36. 17. Letter Combinations of a Phone Number
37. 125. Valid Palindrome
38. 153. Find Minimum in Rotated Sorted Array
39. 283. Move Zeroes
40. 523. Continuous Subarray Sum
41. 658. Find K Closest Elements
42. 670. Maximum Swap
43. 827. Making A Large Island
44. 987. Vertical Order Traversal of a Binary Tree
45. 1757. Recyclable and Low Fat Products
46. 1762. Buildings With an Ocean View
47. 2667. Create Hello World Function
48. 5. Longest Palindromic Substring
49. 15. 3Sum
50. 19. Remove Nth Node From End of List
51. 70. Climbing Stairs
52. 80. Remove Duplicates from Sorted Array II
53. 113. Path Sum II
54. 121. Best Time to Buy and Sell Stock
55. 127. Word Ladder
56. 128. Longest Consecutive Sequence
57. 133. Clone Graph
58. 138. Copy List with Random Pointer
59. 140. Word Break II
60. 142. Linked List Cycle II
61. 145. Binary Tree Postorder Traversal
62. 173. Binary Search Tree Iterator
63. 206. Reverse Linked List
64. 207. Course Schedule
65. 394. Decode String
66. 415. Add Strings
67. 437. Path Sum III
68. 468. Validate IP Address
70. 691. Stickers to Spell Word
71. 725. Split Linked List in Parts
72. 766. Toeplitz Matrix
73. 708. Insert into a Sorted Circular Linked List
74. 1091. Shortest Path in Binary Matrix
75. 1514. Path with Maximum Probability
76. 1609. Even Odd Tree
77. 1868. Product of Two Run-Length Encoded Arrays
78. 2022. Convert 1D Array Into 2D Array
DSA Interview Preparation Resources: https://topmate.io/coding/886874
ENJOY LEARNING ππ
1. 1249. Minimum Remove to Make Valid Parentheses
2. 408. Valid Word Abbreviation
3. 215. Kth Largest Element in an Array
4. 314. Binary Tree Vertical Order Traversal
5. 88. Merge Sorted Array
6. 339. Nested List Weight Sum
7. 680. Valid Palindrome II
8. 973. K Closest Points to Origin
9. 1650. Lowest Common Ancestor of a Binary Tree III
10. 1. Two Sum
11. 791. Custom Sort String
12. 56. Merge Intervals
13. 528. Random Pick with Weight
14. 1570. Dot Product of Two Sparse Vectors
15. 50. Pow(x, n)
16. 65. Valid Number
17. 227. Basic Calculator II
18. 560. Subarray Sum Equals K
19. 71. Simplify Path
20. 200. Number of Islands
21. 236. Lowest Common Ancestor of a Binary Tree
22. 347. Top K Frequent Elements
23. 498. Diagonal Traverse
24. 543. Diameter of Binary Tree
25. 1768. Merge Strings Alternately
26. 2. Add Two Numbers
27. 4. Median of Two Sorted Arrays
28. 7. Reverse Integer
29. 31. Next Permutation
30. 34. Find First and Last Position of Element in Sorted Array
31. 84. Largest Rectangle in Histogram
32. 146. LRU Cache
33. 162. Find Peak Element
34. 199. Binary Tree Right Side View
35. 938. Range Sum of BST
36. 17. Letter Combinations of a Phone Number
37. 125. Valid Palindrome
38. 153. Find Minimum in Rotated Sorted Array
39. 283. Move Zeroes
40. 523. Continuous Subarray Sum
41. 658. Find K Closest Elements
42. 670. Maximum Swap
43. 827. Making A Large Island
44. 987. Vertical Order Traversal of a Binary Tree
45. 1757. Recyclable and Low Fat Products
46. 1762. Buildings With an Ocean View
47. 2667. Create Hello World Function
48. 5. Longest Palindromic Substring
49. 15. 3Sum
50. 19. Remove Nth Node From End of List
51. 70. Climbing Stairs
52. 80. Remove Duplicates from Sorted Array II
53. 113. Path Sum II
54. 121. Best Time to Buy and Sell Stock
55. 127. Word Ladder
56. 128. Longest Consecutive Sequence
57. 133. Clone Graph
58. 138. Copy List with Random Pointer
59. 140. Word Break II
60. 142. Linked List Cycle II
61. 145. Binary Tree Postorder Traversal
62. 173. Binary Search Tree Iterator
63. 206. Reverse Linked List
64. 207. Course Schedule
65. 394. Decode String
66. 415. Add Strings
67. 437. Path Sum III
68. 468. Validate IP Address
70. 691. Stickers to Spell Word
71. 725. Split Linked List in Parts
72. 766. Toeplitz Matrix
73. 708. Insert into a Sorted Circular Linked List
74. 1091. Shortest Path in Binary Matrix
75. 1514. Path with Maximum Probability
76. 1609. Even Odd Tree
77. 1868. Product of Two Run-Length Encoded Arrays
78. 2022. Convert 1D Array Into 2D Array
DSA Interview Preparation Resources: https://topmate.io/coding/886874
ENJOY LEARNING ππ
β€1
π Why Java Feels Harder Than C++ Sometimes π
1. Java: Why write one line when you can write 5? Every variable needs its type, every method needs a class.
C++: Write code anywhere. Procedural, OOP, or just chaos. Your call. π
2. Java: Even the simplest main needs a whole public class. π€‘
C++: Need a main()? Just write it. Done.
3. Java: Checked exceptionsβcatch me or I'll scream. π
C++: Exceptions? Handle them... or donβt. No hard feelings, bro.
4. Java: No unsigned integers. Imagine life without them. Big sad. π
C++: Choose your poisonβint, unsigned, long long. So many options to confuse you.
5. Java: Print something? Get ready: System.out.println(). Keyboard workout. β¨οΈπͺ
C++: cout <<. Done faster than you can say βhello world.β
6. Java: Multi-threading? Write a novel and pray the JVM approves. π
C++: Threading? Use libraries. Use APIs. DIY is the way.
7. Java: Genericsβlooks simple but screams at you later. π€―
C++: Templates are like magic. Dark magicβyouβll debug forever, though.
8. Java: Misspell a package name? Good luck. π¦
C++: Namespaces confuse, but fewer typos.
9. Java: The JVM controls your code and life. ποΈ
C++: Compile once, run anywhereβuntil undefined behavior strikes. π
10. Java: No operators in the name.
C++: The name is an operator. That's how cool it is. π
1. Java: Why write one line when you can write 5? Every variable needs its type, every method needs a class.
C++: Write code anywhere. Procedural, OOP, or just chaos. Your call. π
2. Java: Even the simplest main needs a whole public class. π€‘
C++: Need a main()? Just write it. Done.
3. Java: Checked exceptionsβcatch me or I'll scream. π
C++: Exceptions? Handle them... or donβt. No hard feelings, bro.
4. Java: No unsigned integers. Imagine life without them. Big sad. π
C++: Choose your poisonβint, unsigned, long long. So many options to confuse you.
5. Java: Print something? Get ready: System.out.println(). Keyboard workout. β¨οΈπͺ
C++: cout <<. Done faster than you can say βhello world.β
6. Java: Multi-threading? Write a novel and pray the JVM approves. π
C++: Threading? Use libraries. Use APIs. DIY is the way.
7. Java: Genericsβlooks simple but screams at you later. π€―
C++: Templates are like magic. Dark magicβyouβll debug forever, though.
8. Java: Misspell a package name? Good luck. π¦
C++: Namespaces confuse, but fewer typos.
9. Java: The JVM controls your code and life. ποΈ
C++: Compile once, run anywhereβuntil undefined behavior strikes. π
10. Java: No operators in the name.
C++: The name is an operator. That's how cool it is. π
π10