GDSC DSA WorkShop GDSC Pillai College of Engineering
AnandMenon54
47 views
58 slides
May 31, 2024
Slide 1 of 58
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
About This Presentation
DSA workshop gdsc pce
Size: 6.49 MB
Language: en
Added: May 31, 2024
Slides: 58 pages
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