0% found this document useful (0 votes)
35 views23 pages

Report College

Vhjjn

Uploaded by

latikanarayan217
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
35 views23 pages

Report College

Vhjjn

Uploaded by

latikanarayan217
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 23

INDUSTRIAL TRAINING REPORT

“Data Structure with C++”

Submitted in the Partial Fulfillment for the Award of Degree

Bachelor of Technology in Computer Science & Engineering

Name: Latika Narayan


University Roll No : 2101010140
Semester/Branch: 7 / CSE

SUBMITTED TO:

Department of Computer Science & Engineering

UIT, UTTARANCHAL UNIVERSITY


Dehradun (Uttarakhand), 248001.

1
CERTIFICATE

This is to certify that Mr. / Ms. Latika Narayan has completed the Minor Industrial Training

during the period from 15/4/2024 to 21 /8/2024 in our Organization / Industry as a Partial
Fulfillment of Degree of Bachelor of Technology in Computer Science & Engineering. He / She was trained

in the field of Decode C++ using DSA .

2
DECLARATION

I hereby declare that the Industrial Training Report on Data Structure with C++,
Industry is an authentic record of my own work as requirements of Minor
Industrial Training during the period from 15 /4/ 2024 to 21 /8/ 2024 for the award
of degree of B.Tech. (Computer Science & Engineering), UIT, Uttaranchal
University, Dehradun (U.K.), under the guidance of Assistant Professor Stuti Bhatt.

Date:

Certified that the above statement made by the student is correct to the best
of our knowledge and belief.

Examined by:

(Signature)

Assistant Professor Stuti Bhatt.

(Signature) Head of
Department

3
ACKNOWLEDGEMENT

First and foremost, I wish to express my sincere thanks and gratitude to my

esteemed Mentor Mr. Sanket Singh who has contributed so much for

successful completion of my Industrial Training by his thoughtful reviews and

valuable guidance.

Next I would like to tender my sincere thanks to Professor Dr. Madhu Kirola

for her co-operation and encouragement.

4
TABLE OF CONTENTS
Content .............................................................................................. 1-9

 CERTIFICATE………………………………………………………………………2
 DECLARATION…………………………………………………………………….3
 ACKNOWLEDGEMENT…………………………………………………………...4

CHAPTER

Chapter 1 – Introduction…………………………………………………………………….10

1. PW Skills
o Popular website for developers
o Repository of articles
o Free and paid courses
o Founded by Mr. Alakh Pandey
2. Data Structure –
o Definition and explanation
o Primitive data types
o Arrays (linear data structure)
o Other structures: linked lists, stacks, trees
3. Algorithms
o Definition and importance
o Step-by-step process
o Role in time and space optimization
o Real-world applications

CHAPTER 2 : Introduction to Data Structures …………………. ………………………………………..11-14

2. Introduction
o 2.1 Time Complexity
 Theta (Θ) Notation
 Big O (O) Notation
 Omega (Ω) Notation
o 2.2 Space Complexity
3. Mathematics
o 3.1 Arithmetic and Geometric Progression

5
o 3.2 Mean and Median
o 3.3 LCM and HCF
o 3.4 Modular Arithmetic
4. Bit Magic
o 4.1 Bitwise Operations
 AND, OR, XOR, Shift Operations
o 4.2 Bit Manipulation Problems
 Counting Set Bits
 Finding Unique Elements
 Swapping Bits
5. Recursion
o 5.1 Recursion Basics
o 5.2 Tail Recursion
o 5.3 Examples
 Subset Generation
 Josephus Problem
 String Permutation
6. String
o 6.1 String Functions
 Substring, Concatenation, Length, Comparison
o 6.2 Pattern Searching Algorithms
 Naive Pattern Searching
 Rabin-Karp Algorithm
 KMP Algorithm
7. Data Structure
o 7.1 Array
 Operations: Insertion, Deletion, Rotation, Reversing
 STL Implementations: Vectors and Lists (C++), ArrayList (Java)
8. Searching
o 8.1 Linear Search
o 8.2 Binary Search
o 8.3 Ternary Search
9. Sorting

6
o 9.1 Introduction to Sorting
o 9.2 Types of Sorting Techniques
 Insertion Sort
 Quick Sort
 Merge Sort
 Heap Sort
 Counting Sort
10. Matrix

 10.1 Matrix Operations


o Addition, Subtraction, Multiplication
 10.2 Matrix Rotation
o 90°, 180°, 270°

11. Hashing

 11.1 Hashing Basics


 11.2 Open Addressing

12. Linked List

 12.1 Singly and Doubly Linked Lists


 12.2 Circular and XOR Linked Lists

13. Stack

 13.1 Stack Basics


 13.2 Applications
o Expression Evaluation
o Infix to Postfix Conversion
o Managing Recursion Calls

14. Queue

 14.1 Queue Basics


 14.2 Applications
o Task Scheduling
o Resource Handling

7
15. Deque

 15.1 Deque Basics


 15.2 Applications

16. Tree

 16.1 Binary Tree


 16.2 Binary Tree Operations
o Traversals: In-Order, Pre-Order, Post-Order
o Insertion, Deletion
o Lowest Common Ancestor (LCA)

17. Binary Search Tree (BST)

 17.1 BST Basics


 17.2 Operations
o Searching, Insertion, Deletion
o AVL Trees (Balancing)

18. Heap

 18.1 Heap Basics


 18.2 Heap Operations
o Insertion, Deletion, Heapification

19. Graphs

 19.1 Graph Basics


 19.2 Graph Algorithms
o BFS, DFS
o Dijkstra’s Algorithm
o Minimum Spanning Tree

Chapter 3: Advanced Algorithmic Paradigms ………………………………………….. 15-16

 3.1 Greedy Algorithms


 3.2 Backtracking 8
 3.3 Dynamic Programming (DP)

CHAPTER 4: Projects ..................................................................................................... 17-20

. Hidden Number Hunt


. Wizards word Challenge
CHAPTER 5: CONCLUTION ………………………………………………………………21-22
 Conclusion 

. References

9
CHAPTER – 1
INTRODUCTION
1. PW SKILLS

PW SKILLS is a popular website among the developer community, known for its vast repository of well-crafted

articles that cover various complex topics in computer science. Founded by Mr. Alakh Pandey . The platform

offers valuable resources that are otherwise difficult to find within the computer science community. In addition

to their insightful articles on algorithms and techniques for coding interviews, they provide both free and paid

courses. One of their most popular offerings is the Data Structures and Algorithms (DSA) course, which has

gained immense traction among learners.

2. Data Structure

A Data Structure is an efficient method for organizing and storing data. When handling large amounts of

information, primitive types like int, float, char, and double are insufficient. Instead, more structured forms

like arrays come into play. Arrays, for example, store data in a linear fashion, making them a type of linear data

structure. During my summer internship at PW Skills in the "Decode C++ with DSA" course, under the guidance

of Mr. Sanket Singh, I gained hands-on experience with various data structures, including arrays. Although arrays

are quite useful, they are just one of many types of data structures we explored, such as linked lists, stacks, and

trees, to handle complex data storage efficiently.

3. Algorithms

Real-world applications require precision, efficiency, and optimization in terms of time and memory. This is

where algorithms come into play. In essence, an algorithm is a step-by-step process or a set of instructions to

perform a task. As I deepened my understanding through the internship and the DSA course, I realized how

essential it is to create algorithms that balance time complexity and space complexity for real-world applications.

A poorly designed algorithm can have devastating consequences not only on the application but also on a wider

scale.
10
CHAPTER – 2
INTRODUCTION TO DATASTRUCTURES
1. Introduction
1.1 Time Complexity
Time complexity measures the time required to run an algorithm as a function of the size of the input. Common notations
include:

Theta (Θ) Notation: Describes the exact asymptotic behavior.


Big O (O) Notation: Describes the upper bound (worst-case scenario).
Omega (Ω) Notation: Describes the lower bound (best-case scenario).
Big O notation is commonly used to analyze worst-case performance, which helps identify the time an algorithm may take
in the most demanding scenarios.
1.2 Space Complexity
Space complexity focuses on the amount of memory required by an algorithm, including both the input size and additional
storage used by the algorithm during execution.

2. Mathematics
2.1 Arithmetic and Geometric Progression
Used to identify sequences in mathematical calculations, where numbers follow a pattern of addition (AP) or multiplication
(GP).
2.2 Mean and Median
Statistical measures used to find the average (mean) or the middle value (median) in a data set.
2.3 LCM and HCF
Least Common Multiple (LCM) and Highest Common Factor (HCF) are essential in number theory for finding multiples
and factors of numbers.
2.4 Modular Arithmetic
A system of arithmetic for integers, where numbers wrap around after reaching a certain value, called the modulus.

3. Bit Magic
3.1 Bitwise Operations
Operations on binary digits (bits), including AND, OR, XOR, and Shift operations. These operations are fundamental in
tasks like setting, toggling, or clearing specific bits in data.
3.2 Bit Manipulation Problems
Basic problems such as counting set bits, finding unique elements, and swapping bits can be solved efficiently with bit
manipulation techniques.

4. Recursion
4.1 Recursion Basics
11
Recursion occurs when a function calls itself with a modified argument. Each recursive function requires a base case to
stop the recursive calls.

4.2 Tail Recursion


A form of recursion where the recursive call is the last operation in the function, allowing for optimization by reusing the
function's stack frame.
4.3 Examples

Subset Generation: Finding all possible subsets of a set.


Josephus Problem: A theoretical puzzle where people are eliminated in a circle until only one survives.
String Permutation: Finding all possible arrangements of a string’s characters.
5. String
5.1 String Functions in C++ and Java
Built-in string manipulation functions such as substring, concatenation, length, and comparison functions.
5.2 Pattern Searching Algorithms

Naïve Pattern Searching: A straightforward method to search patterns by sliding the pattern over the text.
Rabin-Karp Algorithm: Uses hashing to find patterns efficiently.
KMP Algorithm: Preprocesses the pattern to reduce the time spent in matching by avoiding redundant comparisons.
6. Data Structure
6.1 Array
An array is a linear data structure where elements are stored in contiguous memory locations.

Operations: Insertion, deletion, rotation, and reversing.


STL Implementations: Using vectors and lists in C++ or ArrayList in Java.
7. Searching
7.1 Linear Search
A basic search algorithm that checks each element of the array one by one until the target element is found.
7.2 Binary Search
A more efficient search algorithm that works only on sorted arrays. It repeatedly divides the array into halves to locate the
target.
7.3 Ternary Search
An extension of binary search that divides the array into three parts instead of two.

8. Sorting
8.1 Introduction to Sorting
Sorting involves arranging data in a specific order, such as ascending or descending.
8.2 Types of Sorting Techniques
12
Insertion Sort: Inserts elements in their proper place within a sorted sub-array.
Quick Sort: Uses divide and conquer to sort elements by partitioning the array.
Merge Sort: Recursively divides the array and merges sorted sub-arrays.
Heap Sort: Converts the array into a heap to sort elements.
Counting Sort: An integer sorting algorithm based on element frequency.
9. Matrix
9.1 Matrix Operations
A matrix is a 2D array of numbers, where operations like addition, subtraction, and multiplication are performed on rows
and columns.
9.2 Matrix Rotation
Rotating the matrix by 90°, 180°, or 270° as part of matrix manipulation.

10. Hashing
10.1 Hashing Basics
Hashing provides an efficient way to store and retrieve data using hash functions that map data to a hash table.
10.2 Open Addressing
A collision-handling method in hash tables where empty slots are searched sequentially for storing collided data.

11. Linked List


11.1 Singly and Doubly Linked Lists
A linear data structure where each element points to the next. Singly lists have one pointer (next), while doubly lists have
two (next and previous).
11.2 Circular and XOR Linked Lists
Circular lists have the last element pointing to the first, and XOR lists use XOR operations on pointers for memory
efficiency.

12. Stack
12.1 Stack Basics
A linear data structure following Last In, First Out (LIFO).
12.2 Applications
Used in expression evaluation, conversion (Infix to Postfix), and managing function calls in recursion.

13. Queue
13.1 Queue Basics
A linear data structure following First In, First Out (FIFO).
13.2 Applications
Used in scheduling tasks, handling resources, and implementing circular queues.

13
14. Deque
14.1 Deque Basics
A double-ended queue allowing insertions and deletions at both ends.
14.2 Applications
Supports both queue and stack operations and can be used in designing data structures with min and max operations.

15. Tree
15.1 Binary Tree
A tree where each node has at most two children.
15.2 Binary Tree Operations
Traversals (in-order, pre-order, post-order), insertion, deletion, and finding the lowest common ancestor (LCA).

16. Binary Search Tree (BST)


16.1 BST Basics
A binary tree where the left child contains values less than the parent node, and the right child contains values greater than
the parent.
16.2 Operations
BST operations include searching, insertion, deletion, and balance using AVL trees.

17. Heap
17.1 Heap Basics
A complete binary tree used for priority queues. It supports operations like finding the minimum/maximum element
efficiently.
17.2 Heap Operations
Insertion, deletion, and heapification to maintain heap properties.

18. Graphs
18.1 Graph Basics
A collection of nodes (vertices) connected by edges.
18.2 Graph Algorithms

BFS and DFS: Traversal methods for exploring nodes.


Dijkstra’s Algorithm: Finds the shortest path in a weighted graph.
Minimum Spanning Tree: Finds the subset of edges connecting all vertices with the least weight.

14
CHAPTER – 3
ADVANCE ALGORITHMS
3.1 Greedy Algorithms

Greedy is an algorithmic paradigm that builds solutions step-by-step, always picking the immediate, most beneficial option.
It works well for problems where choosing the locally optimal solution also leads to the globally optimal solution.

3.1.1 Key Concept:

Always choose the most beneficial option at each step.

3.1.2 What We Learnt:

Job Sequencing Problem: A classic problem solved using the Greedy algorithm by optimizing tasks based on their deadlines
and profits.

3.2 Backtracking

Backtracking is a recursive algorithmic technique for solving problems by incrementally building a solution and discarding
those that don’t meet the constraints. It allows us to explore all possibilities and "backtrack" when necessary.

3.2.1 Key Concept:

Build a solution piece by piece.

Remove solutions that violate constraints at any step.

3.2.2 What We Learnt:

3.2.2.1 Rat in a Maze: Solving a pathfinding problem using recursive backtracking.

3.2.2.2 N-Queen Problem: Placing queens on a chessboard such that no two queens attack each other.

3.2.2.3 Sudoku Problem: Solving a Sudoku puzzle by filling numbers in a grid while maintaining valid conditions.

3.3 Dynamic Programming (DP)

Dynamic Programming is an efficient method used to solve complex problems by breaking them down into simpler sub-
problems and storing the results of these sub-problems to avoid redundant computations.

3.3.1 Key Concept:

Store results of previous calculations to avoid recomputation.

3.3.2 What We Learnt:

15
3.3.2.1 Properties of Dynamic Programming Problems:

Overlapping Subproblems: Sub-problems recur during the solution process.

Optimal Substructure: An optimal solution to the problem contains an optimal solution to its sub-problems.

16
CHAPTER – 4
PROJECTS
4.1 Hidden Number Hunt

Objective:
The goal of the Hidden Number Hunt game is to find a hidden number within a range using a
series of guesses. The program provides feedback to the player, whether the guessed number is
too high or too low, to narrow down the search.

Steps Involved:

The program randomly selects a number from a predefined range (e.g., 1 to 100).
The player is prompted to guess the number.
After each guess, the program tells whether the guess is too high or too low.
The game continues until the player correctly guesses the hidden number.

What we learnt:

Implementing random number generation


Loops and conditionals for user interaction
Providing feedback based on user input
Validating user input

Code Syntax:

#include <iostream>
#include <cstdlib> // for rand() and srand()
#include <ctime> // for time()

using namespace std;

int main() {
srand(time(0)); // seed the random number generator
int hiddenNumber = rand() % 100 + 1; // generates a number between 1 and 100
int guess;
int attempts = 0;
17
cout << "Welcome to Hidden Number Hunt! Guess the number between 1 and 100.\n";

do {
cout << "Enter your guess: ";
cin >> guess;
attempts++;

if (guess > hiddenNumber) {


cout << "Too high! Try again.\n";
} else if (guess < hiddenNumber) {
cout << "Too low! Try again.\n";
} else {
cout << "Congratulations! You found the hidden number in " << attempts << "
attempts.\n";
}
} while (guess != hiddenNumber);

return 0;
}

Output:

4.2 Wizards Word Challenge

Objective:
Wizards Word Challenge is a word-guessing game where the player has to guess a secret word by guessing individual
letters. The game gives feedback on correct and incorrect guesses, revealing letters in the word as they are guessed.

Steps Involved:

A word is chosen at random from a list of possible words.


The player guesses one letter at a time.
18
If the guessed letter is in the word, it is revealed in its correct position.
The game continues until the player either guesses the word or runs out of attempts.

What we learnt:
Managing strings and character arrays
Using loops and conditionals for game logic
Keeping track of correct and incorrect guesses
Revealing parts of the word dynamically

Code Syntax:
#include <iostream>
#include <string>
#include <vector>
using namespace std;

int main() {
vector<string> words = {"wizard", "magic", "dragon", "potion", "spell"};
srand(time(0));
string secretWord = words[rand() % words.size()]; // pick a random word from the list
string guessedWord(secretWord.length(), '_'); // initially, all letters are hidden
int attempts = 7;
char guess;
bool correctGuess;

cout << "Welcome to Wizards Word Challenge! Guess the magical word.\n";

while (attempts > 0 && guessedWord != secretWord) {


correctGuess = false;
cout << "Word: " << guessedWord << "\n";
cout << "You have " << attempts << " attempts left. Enter a letter: ";
cin >> guess;

// Check if the guessed letter is in the word


for (size_t i = 0; i < secretWord.length(); i++) {
if (secretWord[i] == guess) {
guessedWord[i] = guess;
correctGuess = true;
}
}

if (!correctGuess) {
attempts--;
cout << "Wrong guess! Try again.\n";
}

if (guessedWord == secretWord) {
cout << "Congratulations! You've guessed the word: " << secretWord << endl;

19
} else if (attempts == 0) {
cout << "You've run out of attempts! The word was: " << secretWord << endl;
}
}
return 0;
}

Output:

20
Chapter - 5
Conclusion

Algorithm is vast topic and it is all about making a program more efficient. These Algorithms arethe ones that

make our experience smother with the software. Take google search engine for example how fast it provides the

best search result in few seconds of times. That is the power of algorithms. That is why many companies ask

questions related to algorithms during interview.

Through this Course I have Learnt a vast number of interesting topics like Trees, Graphs, LinkedList and many

other more. Their implementation in practical problems and understanding their base concepts.

While working in IT sector we need to solve the problems and make programs write tons of codewhich will help

us with the given problem and to write a program one need to make different algorithms. Many algorithms

combine to make a program. Now, algorithm are writen in some lenguages but they are not dependen ton them,

one need to make a plan and algo first then write it into any language wether i tis C++ or JAVA or C or any other

programing language. Algorithmis based on data structure and its implementation and working. So, basiclly one

need to have a good grip on DSA to work in programing sector.

21
References

1. https://en.cppreference.com/w/

2. https://www.geeksforgeeks.org/rand-and-srand-in-ccpp/

3. https://www.geeksforgeeks.org/building-simple-guessing-game-c/

4. https://www.cplusplus.com/reference/string/string/

5. https://www.programiz.com/cpp-programming/if-else

6. https://www.udacity.com/course/c-plus-plus-game-programming--ud162

22
23

You might also like