SamiTech Code
340 subscribers
130 photos
12 videos
4 files
86 links
Computer Science student and software developer focused on building impactful products, exploring AI, and solving real-world challenges with technology.
My portfolio.... sami.pro.et

“Your efforts today are your goals tomorrow.”
Download Telegram
Python list looks like this👆 and the first box is index of 0 then 1,2,3,4 to understand list of index we can calculate like this index = length - 1. eg; a[0] = 10, a[1] = 20, a[2] =' GfG', a[3] = 40, a[4] = 'True' questions what's a[-1] your answer in the comment sections↩️
here I've prepared the topics we'll going to focus one by one
DATA STRUCTURE:
Array DS, String in DS, Set, Dictionary, Recursion, Linked List DS, Stack DS, Queue DS, hash in DS, Tree DS, Heap in DS, Graph DS, Trie DS

ALGORITHMS: Searching Algorithms, Sorting Algorithms, Tree Traversal, Graph Algorithms,

PROBLEM SOLVING TECHNIQUES: Two Pointers, Sliding Window, Recursion, Dynamic Programming(DP), Greedy

May be this course takes time don't worry we'll learn from each others, ask questions, and share info. Let's go together and become mastered in DSA💪
Searching Algorithm: There are 2 types of SA 1. Linear Search & 2. Binary Search from them here; 1. Linear Search in diagram in easy way👆 let me know what you've understand from this 👀
👍1
SamiTech Code pinned «here I've prepared the topics we'll going to focus one by one DATA STRUCTURE: Array DS, …»
Good Night😴
Good Morning Guys🌄
We'll not stop our learning journey to ML
👍1
Array Search: Given an array, arr[] of n integers, and an integer element x, find whether element x is present in the array. Return the index of the first occurrence of x in the array, or -1 if it doesn't exist
input: arr[] = [1,2,3,4], x = 3 output: 2 Explanation: For array [1, 2, 3, 4], the element to be searched is 3. Since 3 is present at index 2, the output is 2. Input: arr[] = [10, 8, 30], x = 6
Output: -1
Explanation: The element to be searched is 6 and it is not present, so we return -1.

This's Linear Search O(n)👆🏻 Try to think this problem before jumping into code🤔
SamiTech Code
Array Search: Given an array, arr[] of n integers, and an integer element x, find whether element x is present in the array. Return the index of the first occurrence…
Code Implementation👆🏻
class Solution:
def search(self, arr, x):
# Code with the logical error fixed
for n in range(len(arr)):
if arr[n] == x:
return n # Return the index if found

# Only return -1 after the entire loop has completed,
# meaning the element was not found in the entire list.
return -1

arr = [1, 2, 3, 4]
x = 3
# Create an instance of the class to call the instance method
sol_instance = Solution()
print(sol_instance.search(arr, x))

I wish you understand the logic! in the next I'll share for you some applications of Linear Search(Sequential Search)👌
👏3
Applications of Linear Search Algorithm:
Unsorted Lists:
When we have an unsorted array or list, linear search is most commonly used to find any element in the collection.
Small Data Sets: Linear Search is preferred over binary search when we have small data sets with
Searching Linked Lists: In linked list implementations, linear search is commonly used to find elements within the list. Each node is checked sequentially until the desired element is found.
Simple Implementation: Linear Search is much easier to understand and implement as compared to Binary Search or Ternary Search.

👉🏽In The next step we'll learn about Binary Search this's very important while learning DSA😁
👉🏽For more info this pdf is important you can study it it's organized, clarifications, and also problem-solving. It contains Linear Search and Binary Search https://projector-video-pdf-converter.datacamp.com/29490/chapter3.pdf
SamiTech Code pinned «Array Search: Given an array, arr[] of n integers, and an integer element x, find whether element x is present in the array. Return the index of the first occurrence…»
Good Night guys🫡
Good Morning everyones🌅
3
Binary Search definition: Binary search is an efficient search algorithm that locates the position of a target value within a sorted array by repeatedly dividing the search interval in half. This "divide and conquer" strategy gives it a logarithmic time complexity of O(log N), making it significantly faster than linear search for large datasets.
👍1
👆🏻Understanding this process is important in binary search. So try to think about it how we can search for 7 after you understand this you'll gain different between binary & linear search. In addition you can say which is more efficient and not😁 Don't be hesitate this course it's truly interesting👌
Keep in mind this: For now let focus on the core algorithms but we can learn later the left one. For the next topic stay tuned💪🏻
2️⃣POINTER TECHNIQUE Still now on studying...🧑‍💻
Hey I was searching for two pointer technique in Youtube even google but noting changed but finally I asked Chatgpt this In a way I can understand can you just give me two pointer clarification in easy way without memorizing them🥹
after then chatgpt gives me this👇 First: Forget the Name “Two Pointer”
Don’t think “two pointer technique”.
Think only this:
“How can I look at two places in the array at the same time and move intelligently?”
That’s it.

I loved the way chatgpt clarify this concept for me🥰 Not only this.. and Try to ask chatgpt in your own thought then after then you'll explain about two pointer in your own word. if so the implementation part is simple. 👉🏽DO YOU KNOW AT THE FIRST THINKING IS IMPORTANT THEN YOU DO WHAT YOU THINK.👌 this's all about problem solving technique
👏2
SamiTech Code pinned «Binary Search definition: Binary search is an efficient search algorithm that locates the position of a target value within a sorted array by repeatedly dividing the search interval in…»