GDSC DSA WorkShop GDSC Pillai College of Engineering

AnandMenon54 47 views 58 slides May 31, 2024
Slide 1
Slide 1 of 58
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9
Slide 10
10
Slide 11
11
Slide 12
12
Slide 13
13
Slide 14
14
Slide 15
15
Slide 16
16
Slide 17
17
Slide 18
18
Slide 19
19
Slide 20
20
Slide 21
21
Slide 22
22
Slide 23
23
Slide 24
24
Slide 25
25
Slide 26
26
Slide 27
27
Slide 28
28
Slide 29
29
Slide 30
30
Slide 31
31
Slide 32
32
Slide 33
33
Slide 34
34
Slide 35
35
Slide 36
36
Slide 37
37
Slide 38
38
Slide 39
39
Slide 40
40
Slide 41
41
Slide 42
42
Slide 43
43
Slide 44
44
Slide 45
45
Slide 46
46
Slide 47
47
Slide 48
48
Slide 49
49
Slide 50
50
Slide 51
51
Slide 52
52
Slide 53
53
Slide 54
54
Slide 55
55
Slide 56
56
Slide 57
57
Slide 58
58

About This Presentation

DSA workshop gdsc pce


Slide Content

DSA Workshop (Day 1)

About me DSA/CP Lead @GDSC PCE In top 7.93% of all users on leetcode Max Rating (1355) on Codeforces Solved over 1500+ DSA/CP problems Smart India Hackathon 2019 Finalist Full Stack Developer (MERN) Stack YASH DABHADE TY COMPS

01 Brush up basics Contents of the workshop 02 Intro to DSA 03 Time and Space Complexity

04 Arrays Contents of the workshop 05 Stacks 06 Queues

07 HashMap Contents of the workshop 08 LinkedList 09 Searching

Brush up basics 01

Intro to Programming A programming language is a set of instructions written by a programmer to tell a computer how to perform a task Some popular languages

Data Types Data types are used to inform a programming language's compiler or interpreter about the data that will be used. Data Types are classified as : Pre Defined User Defined

Variables Variables are containers for storing data values. Syntax : data_type variable_name; Scopes of Variables : Local Variable Global Variable

Scope of variable

Operators Arithmetic Operators

Operators Assignment Operators

Operators Relational Operators

Operators Logical Operators

Operators Bitwise Operators

Conditional Statements Conditional statements in C++ are control structures that let code make decisions Syntax : if (condition) { code… } else{ Code.. }

Example of if-else

I terative Statements The looping can be defined as repeating the same process multiple times until a specific condition satisfies. Types of loops :

While loop

Do-while loop

For loop

Functions A function is a block of code that performs a specific task. Functions are classified as : Standard Library Functions User-defined Function

User-defined Function

Pointers A pointer however, is a variable that stores the memory address as its value. Syntax : data_type *pointer_name = address; Applications of pointers: Operating System Various Data Structures

Introduction to DSA 02

Introduction to DSA Data Structures and Algorithms (DSA) is a fundamental part of Computer Science that teaches you how to think and solve complex problems systematically. Benefits of Learning DSA : Improve problem solving skills Able to perform better in Online Assessment Easily able to code complex logics Breaking a problem into small pieces and making working solutions for them

Myth DSA is boring and not used in real life

Language to choose Speed : Fastest Fast Slow Available 90% 8% 2% Solutions: Library STL Collection Inbuilt Modules Used :

Platforms Available Pure DSA Competitive Programming

Time Complexity What is Time Complexity ? Types of Time Complexity Why it is important ?

TC Cheatsheet

How to calculate TC x=y+10-z O(1) Time Complexity x=2*y+z O(1) Time Complexity if(x>y and z*2>y){ O(1) Time Complexity cout<<x<<endl; }

How to calculate TC for(int i=0;i<n;i++) { O(n) Time Complexity cout<<i<<endl; } for(int i=0;i<n;i++{ O(n^2) Time Complexity for(int j=0;j<n;j++){ cout<<i<<” “<<j<<endl; } }

How to calculate TC for(int i=0;i<n;i++{ O(n^3) Time Complexity for(int j=0;j<n;j++){ for(int j=0;j<n;j++){ cout<<i<<” “<<j<<” “<<k<<endl; } } } int n=1000; O(log2(n)) Time Complexity while(n>2) { n/=2; }

Space Complexity What is Space Complexity ? Why it is important ?

Space Complexity Int arr[n]; for(int i=0;i<n;i++) { O(n) Space Complexity cout<<arr[i]<<endl; } Int arr[n][n]; for(int i=0;i<n;i++{ O(n^2) Space Complexity for(int j=0;j<n;j++){ cout<<arr[i][j]<<endl; } }

Classification 01 Linear (Arrays, Stacks, Queues, LinkedList) Data Structures 02 Non Linear (HashMap, Graphs, Trees)

Arrays/Vectors What is Arrays ? How vectors are different ? Functions in Vectors : push_back(element) pop_back() back() erase() clear() Vector in C++ 0 1 2 3 4

Vector Functions

Let’s solve problems https://leetcode.com/problems/buy-two-chocolates/ https://leetcode.com/problems/move-zeroes/description/

Stacks What is Stack? LIFO Data Structure Functions : push(element) pop() top() size() empty() clear()

Stack Functions

Let’s solve problems https://leetcode.com/problems/valid-parentheses/ https://leetcode.com/problems/removing-stars-from-a-string/description/?envType=study-plan-v2&envId=leetcode-75

Queue What is Queue? F IFO Data Structure Functions : push(element) pop() front() back() empty() size()

Queue Functions

Circular Queue Double Ended Queue

Priority Queue What is Priority Queue? Min-Heap/Max-Heap Functions : push(element) pop() top() empty() size()

HashMap What is HashMap ? Constraints on HashMap

Pair What is pair? Can we pair elements of different data type ?

Problems https://leetcode.com/problems/sort-characters-by-frequency/

Linked List What is Linked List ? Why Linked List is not preferred ? Functions : Not inbuilt data structure

Types of Linked List Doubly Linked List

Problems https://leetcode.com/problems/reverse-linked-list/ Try this on your own : https://leetcode.com/problems/add-two-numbers/description/

Searching (Linear) Why is searching required ? Types of search : Linear Search Binary Search

Problems (Linear) https://leetcode.com/problems/binary-search/description/ https://leetcode.com/problems/minimum-common-value/?envType=daily-question&envId=2024-03-11

Miscellaneous Problems https://leetcode.com/problems/custom-sort-string/?envType=daily-question&envId=2024-03-11 https://leetcode.com/problems/missing-number/description/?envType=daily-question&envId=2024-03-11

Thanks! Feel free to ask any questions? https://twitter.com/YashD283 https://www.linkedin.com/in/yashdabhade283/
Tags