Skip to content

Instantly share code, notes, and snippets.

@CastonPursuit
Last active June 7, 2023 20:24
Show Gist options
  • Save CastonPursuit/e1e36b46186464995e2fb66429960445 to your computer and use it in GitHub Desktop.
Save CastonPursuit/e1e36b46186464995e2fb66429960445 to your computer and use it in GitHub Desktop.

Intro to DSA

Time: 1 hr 30 mins - 2 hrs

πŸ“œ Slides

Link to Slides

🎯 Learning Objectives

By the end of this lesson, participants will be able to:

  • πŸ’‘ Understand and explain the purpose and importance of data structures and algorithms.
  • πŸ“š Identify and describe common data structures and their characteristics.
  • πŸ’ͺ Feel confident and motivated to continue exploring and learning about data structures and algorithms.
  • 🎯 Apply the P.E.D.A.C. problem-solving framework to solve coding problems for CodeWars and technical interviews.

Lesson Outline

  1. Introduction to the Lesson and the Importance of DSA (5 minutes)
  2. Icebreaker Activity: Connecting DSA to Everyday Life (10 minutes)
  3. Introduction to Data Structures (15 minutes)
  4. Interactive Activity: Exploring Data Structures (15 minutes)
  5. Introduction to Algorithms (15 minutes)
  6. Interactive Activity: Analyzing Algorithms (15 minutes)
  7. Introduction to P.E.D.A.C. (10 minutes)
  8. Practice P.E.D.A.C. (15 minutes)
  9. Overview of Assignment: CodeTrack and Codewars (10 minutes)
  10. Check for Understanding (5 minutes)

πŸš€ Introduction to the Lesson and the Importance of DSA

(5 minutes)

πŸ’‘ Coding Efficiency
  • Understanding DSA enables you to optimize code efficiency by selecting appropriate data structures and implementing efficient algorithms.

  • Efficient code leads to improved performance, scalability, and reduced resource consumption in real-world applications.

πŸ’Ό Employers and Technical Interviews
  • Employers value DSA proficiency as it demonstrates your ability to solve complex problems and write efficient code.

  • Technical interviews often assess candidates' DSA knowledge to evaluate their problem-solving skills and coding efficiency.

πŸ“š Data Structures and Algorithms
  • Participants will learn about essential data structures such as arrays, linked lists, stacks, queues, trees, and graphs.

  • They will understand the characteristics, operations, and use cases of each data structure.

  • Participants will explore common algorithms including searching, sorting, graph traversal, and dynamic programming.

  • They will gain insights into algorithmic complexity, time complexity, and space complexity analysis.

  • Participants will understand the importance of efficient algorithms in optimizing code performance and solving complex problems.

πŸ™‹ Icebreaker Activity: Connecting DSA to Everyday Life

(10 minutes)

Poll Question:

When organizing your clothes during room cleaning, which approach do you find most effective?

  1. Baskets: Sorting clothes into different baskets based on categories (e.g., shirts, pants, socks).
  2. Piles on Bed: Sorting clothes into separate piles on the bed based on color (e.g., all whites, all blacks, all colors).
  3. Type of Clothing: Sorting clothes into separate piles on the bed based on the type of clothing (e.g., shirts, pants, dresses).
  4. By Outfit: Organizing clothes by complete outfits, grouping together matching tops and bottoms.

πŸ“š Introduction to Data Structures

(15 minutes)

♻️ Recap and Connection: Recap the importance of data structures in coding efficiency and problem-solving.
  • Emphasize the relevance of the earlier polling activity and its connection to data structures.
🌎 Real-world Examples: Share practical examples of data structures in use.
  • Contact List: Discuss how an array or linked list can be used to store and organize contacts in a phone or email application.

  • Shopping Cart: Explain how a stack or a linked list can be utilized to maintain and manage items in a shopping cart during online shopping.

  • Music Playlist: Highlight the use of a linked list or an array to create and manage a music playlist, allowing users to add, remove, or reorder songs.

πŸ“š Key Data Structures: Introduce arrays, linked lists, stacks, and queues.
  • Arrays: Explain that arrays are data structures that store a fixed-size sequence of elements of the same type.

  • Linked Lists: Describe linked lists as data structures consisting of nodes, where each node holds a value and a reference to the next node.

  • Stacks: Introduce stacks as data structures that follow the Last-In-First-Out (LIFO) principle, where elements are added and removed from one end.

  • Queues: Define queues as data structures that follow the First-In-First-Out (FIFO) principle, where elements are added at one end and removed from the other.

πŸ—οΈ Breakout Room Activity: Exploring Data Structures

(15 minutes)

Activity Details
  • Encourage participants to discuss and answer the following guiding questions during their breakout room session:

    1. What are the main characteristics and properties of the assigned data structure?
    2. How does the data structure store and organize its elements?
    3. What are the typical operations that can be performed on this data structure?
  • Facilitate group discussions, address questions or clarifications, and promote active participation.

  • Bring the participants back together and allow each group to share their findings and insights about their assigned data structure.

  • Facilitate a brief discussion to highlight the different data structures and their features.

πŸ”Ž Introduction to Algorithms

(15 minutes)

♻️ Recap and Connection: Recap the importance of algorithms in problem-solving and efficient programming.
  • Emphasize the relevance of algorithms in optimizing code performance and achieving desired outcomes.
🌎 Real-world Examples: Discuss everyday scenarios where algorithms are used.
  • Searching Algorithms: Explore how search algorithms are used in finding information on the internet or searching for a specific item in a store.

  • Sorting Algorithms: Explain how sorting algorithms can be seen in organizing items in a to-do list or arranging files in a computer directory.

  • Recommendation Algorithms: Highlight the use of algorithms in suggesting movies, music, or products based on user preferences.

πŸ“š Key Algorithms: Introduce fundamental algorithms used in problem-solving.
  • Linear Search: Demonstrate how linear search is used in finding a specific element in an unordered list by checking each element one by one.

  • Binary Search: Explain binary search as a more efficient algorithm for finding a specific element in a sorted list by repeatedly dividing the search space in half.

  • Bubble Sort: Introduce bubble sort as a simple algorithm for arranging a list of numbers in ascending order by repeatedly swapping adjacent elements.

🎲 Interactive Activity: Analyzing Algorithms

Zoom Poll Questions: Algorithm Identification
  1. Given the algorithm that repeatedly swaps adjacent elements to arrange a list of numbers in ascending order, which algorithm is this?

    • A. Linear Search
    • B. Binary Search
    • C. Bubble Sort
  2. When searching for a specific element in an unordered list by checking each element one by one, which algorithm is commonly used?

    • A. Linear Search
    • B. Binary Search
    • C. Bubble Sort

🎯 Introduction to P.E.D.A.C.

(10 minutes)

πŸ’‘ Purpose of P.E.D.A.C
  • Explain the purpose of P.E.D.A.C (Problem, Examples, Data Structure, Algorithm, Code) as a problem-solving framework.
  • Emphasize its importance in breaking down and approaching coding problems systematically.
✏️ Overview of P.E.D.A.C Process
  • Provide a high-level overview of each step in the P.E.D.A.C process:
    • Problem: Understand and define the problem.
    • Examples: Work through examples and gather requirements.
    • Data Structure: Determine appropriate data structures to use.
    • Algorithm: Design an algorithm to solve the problem.
    • Code: Implement the algorithm in code.
βœ… Walkthrough Example
  • Choose a simple coding problem that can be easily solved using P.E.D.A.C.
  • Walk through each step of the P.E.D.A.C process for the selected problem, explaining the thought process and decisions made at each stage.

Given a list of numbers, find the sum of all the numbers. Inputs: List of numbers Output: Sum of the numbers in the list Constraints: The list may contain both positive and negative numbers.

♻️ Recap and Key Takeaways
  • Summarize the main points covered during the P.E.D.A.C introduction and example walkthrough.
  • Emphasize the importance of practicing the P.E.D.A.C process for problem-solving in coding.

✍️ Practice P.E.D.A.C.

Click to Expand Details

Introduction

(5 minutes)

  • Explain that the participants will engage in a collective class activity to practice the P.E.D.A.C process for a coding problem.
  • Emphasize that each participant will contribute their thoughts and ideas in the chat for each step of P.E.D.A.C.

Problem Statement

Problem: Given an array of integers, write a function to find the maximum element in the array.

P.E.D.A.C Process
### 1. Problem
- Define the problem: Find the maximum element in an array of integers.
- Requirements: The function should take an array of integers as input and return the maximum element.

### 2. Examples
- Examples:
  - Input: [1, 5, 3, 9, 2]
    Output: 9
  - Input: [-2, 0, -5, -1]
    Output: 0

### 3. Data Structure
- Data Structure: No specific data structure is needed for this problem.

### 4. Algorithm
- Algorithm:
  - Initialize a variable `max` to store the maximum element.
  - Iterate through the array:
    - If the current element is greater than `max`, update `max` with the current element.
  - Return `max`.

### 5. Code
   function findMax(arr) {
      let max = arr[0];
      for (let i = 1; i < arr.length; i++) {
        if (arr[i] > max) {
         max = arr[i];
        }
      }
      return max;
   }
## Sharing and Discussion
- Allow participants to share their thoughts, approaches, and code snippets in the chat for each step.
- Facilitate a discussion to compare different approaches and code implementations.
- Address any questions or doubts raised by participants.

## Wrap-up
- Summarize the key takeaways from the practice activity, emphasizing the importance of using the P.E.D.A.C process for problem-solving in coding.
- Encourage participants to continue practicing P.E.D.A.C and exploring more coding problems.

πŸ“‹ Overview of Assignment: CodeTrack and Codewars

(10 minutes)

Click to expand details
  • Direct the participants to the CodeTrack and Codewars platforms where they will find a collection of coding problems.

  • Emphasize the importance of practicing problem-solving skills and applying the concepts learned in this lesson.

  • Spark the drive for participants to challenge themselves and solve as many problems as possible, just like training to improve their skills.

  • Encourage participants to track their progress, set goals, and engage in the coding community to learn from others and share their solutions.

βœ… Check for Understanding

Questions
  1. What is the importance of learning data structures and algorithms in coding?

  2. Name two real-world examples where data structures are commonly used.

  3. Briefly explain the difference between linear search and binary search algorithms.

  4. What are the steps involved in the P.E.D.A.C process for problem-solving?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment