Skip to content

Python Data Structure and Algorithms For Cracking Coding Interviews 😎

License

Notifications You must be signed in to change notification settings

ChinmayaBisoi/Python-DSA

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

4 Commits
Β 
Β 
Β 
Β 

Repository files navigation

Python-DSA

Python Data Structure and Algorithms For Cracking Coding Interviews 😎

Algorithms and data structures are fundamental to efficient code and good software design. Creating and designing excellent algorithms is required for being an exemplary programmer. This repository's goal is to demonstrate how to correctly implement common data structures and algorithms in the simplest and most elegant ways.


Contents

B - Beginner, A - Advanced

  • B List

List in Python

Lists are one of the fundamental built-in data types in python. They are collection of items which internally uses Array Data Structures.

However unlike in languages like C++, . Also, Python Lists allows us to store . Here are some properties of python lists :

  • Python Lists are dynamic in nature, meaning its size grows or shrinks according to data stored or deleted
  • It is zero-indexed meaning that the first element has index 0
  • It allows duplicate items
  • It is ordered in nature
  • It allows us to store different data types in a single list itself

Here's how to declare a list called "A" that has elements 20,40,60,10,20 in the same order

A = [20,40,60,10,20]

In the above code the, first element of "A" is 20 and its index is 0, second element of "A" is 40 and its index is 1, third element of "A" is 60 and its index is 2, fourth element of "A" is 10 and its index is 3, fifth element of "A" is 20 and its index is 4

Accessing elements in list

A = [20,40,60,10,20]

# Accessing the 1st element 
print(A[0])

# Accessing element 60
print(A[2])

Output

20
60

Changing elements in list

A = [20,40,60,10,20]

# Changing the element 40 to say 100 or
A[1] = 100
print(A)

# Changing the 3rd element to 90 
A[2] = 90
print(A)

Output

[20, 100, 60, 10, 20]
[20, 100, 90, 10, 20]

About

Python Data Structure and Algorithms For Cracking Coding Interviews 😎

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published