Relational ALgebra & SQL
Introduction to Data Structure
Data Structure is a technique or method of study how the data are interrelated to each other logically or mathematically
Data Structure হলো এমন একটি পদ্ধতি বা কৌশল, যার মাধ্যমে logical বা mathematical ভাবে পরস্পর সম্পর্কযুক্ত ডাটা গুলো নিয়ে অধ্যয়ন করা হয়।

1. Linear Data Structure
Linear data structures arrange data elements sequentially, where each element is connected to its previous and next adjacent elements.
Example: Array, Stack, Queue, Linked List, etc.
2. Static Data Structure
In static data structures, the memory size is fixed at compile time, and elements can be accessed directly using indices.
Example: Array.
3. Dynamic Data Structure
In dynamic data structures, the memory size flexibly expands or shrinks at runtime. Memory is used efficiently, but resizing may cause some overhead.
Example: Queue, Stack, etc.
4. Non-Linear Data Structure
Non-linear data structures do not arrange elements sequentially. Elements are organized hierarchically or in networks, allowing multiple connections. Traversing all elements in a non-linear data structure is not possible in a single pass.
Example: Trees, Graphs.
১. লিনিয়ার ডাটা স্ট্রাকচার
এখানে ডাটা উপাদানগুলো ধারাবাহিকভাবে সাজানো থাকে, যেখানে প্রতিটি উপাদান তার আগের এবং পরের উপাদানের সাথে সংযুক্ত থাকে।
উদাহরণ: অ্যারে, স্ট্যাক, কিউ, লিংকড লিস্ট ইত্যাদি।
২. স্ট্যাটিক ডাটা স্ট্রাকচার
স্ট্যাটিক ডাটা স্ট্রাকচারে মেমোরির আকার কম্পাইল টাইমে নির্ধারিত হয়ে যায় এবং ইন্ডেক্স ব্যবহার করে সরাসরি উপাদানগুলো অ্যাক্সেস করা যায়।
উদাহরণ: অ্যারে।
৩. ডায়নামিক ডাটা স্ট্রাকচার
ডায়নামিক ডাটা স্ট্রাকচারে মেমোরির আকার রানটাইমে বাড়ানো বা কমানো যায়। এতে মেমোরি কার্যকরভাবে(efficiently) ব্যবহার করা হয়, তবে মেমোরি রিসাইজ করার সময় কিছু ওভারহেড হতে পারে।
উদাহরণ: কিউ, স্ট্যাক ইত্যাদি।
৪. নন-লিনিয়ার ডাটা স্ট্রাকচার
নন-লিনিয়ার ডাটা স্ট্রাকচারে উপাদানগুলো ধারাবাহিকভাবে সাজানো থাকে না। এখানে উপাদানগুলো স্তরভিত্তিক(hierarchical) বা নেটওয়ার্ক আকারে সংযুক্ত থাকে, যেখানে একাধিক কানেকশন সম্ভব। নন-লিনিয়ার ডাটা স্ট্রাকচারের সব উপাদান একবারে ট্রাভার্স করা সম্ভব নয়।
উদাহরণ: ট্রি, গ্রাফ।
Data Structure Operation
1. Insertion:Adding a new element or node into the data structure.
2. Deletion:Removing an element or node from the data structure.
3. Search: Finding an element or node within the data structure.
4. Update: Modifying an existing element or node in the data structure.
5. Traversal: Visiting every element or node in the data structure in a specific order.
6. Merge: Combining two or more data structures into one.
7. Access: Retrieving an element or node from the data structure by its position or key.
১. Insertion: Data Structure এ একটি নতুন উপাদান বা node যোগ করা।
২. Deletion: Data Structure থেকে একটি উপাদান বা node মুছে ফেলা।
৩. Search: Data Structure এ একটি উপাদান বা node খুঁজে বের করা।
৪. Update: Data Structure এ একটি বিদ্যমান উপাদান বা node সংশোধন করা।
৫. Traversal: Data Structure এ প্রতিটি উপাদান বা node একটি নির্দিষ্ট অর্ডারে পরিদর্শন করা।
৬. Merge:দুটি বা ততোধিক Data Structure একত্রিত করা।
৭. Access: Data Structure এর একটি উপাদান বা node তার অবস্থান বা key দ্বারা পুনরুদ্ধার করা।
Learning Data Structures and Algorithms (DSA) is crucial for efficient problem-solving, job interviews at top tech companies, improving coding skills, solving real-world problems, gaining a competitive edge in programming contests, adapting to new technologies, and enhancing decision-making skills. Mastering DSA allows you to write efficient, cleaner code, solve complex problems, and stay competitive in the fast-evolving tech industry.
Data Structures এবং Algorithms শেখার গুরুত্ব কী?
ডাটা স্ট্রাকচার ও অ্যালগরিদম (DSA) শেখা প্রতিটি প্রোগ্রামারের জন্য অপরিহার্য, কারণ এটি জটিল সমস্যা সমাধানের দক্ষতা বাড়ায়, গুগল-মাইক্রোসফটের মতো টপ টেক কোম্পানির ইন্টারভিউতে সাফল্য এনে দেয়, কোডিং দক্ষতা উন্নত করে, বাস্তব জীবনের চ্যালেঞ্জিং সমস্যা সমাধানে সাহায্য করে, ACM ICPC বা Google Code Jam-এর মতো প্রোগ্রামিং প্রতিযোগিতায় এগিয়ে রাখে, নতুন প্রযুক্তি শিখতে গতি দেয় এবং সিদ্ধান্ত গ্রহণের দক্ষতা বাড়িয়ে যৌক্তিক চিন্তার দক্ষতা উন্নত করে।
- Operating Systems: For managing hardware resources and running applications smoothly.
- Database Systems: To store, retrieve, and manage data efficiently.
- Web Applications: For handling user requests and data processing.
- Machine Learning: To process large datasets and train models effectively.
- Video Games: For game logic, graphics rendering, and real-time user interaction.
- Cryptography: To secure data through complex encryption algorithms.
- Data Analysis: For sorting and interpreting large amounts of information.
- Search Engines: To crawl websites and deliver relevant search results quickly.
- Social Networks: Platforms like Facebook use data structures to model connections between friends.
- Navigation Systems: GPS apps use algorithms to find the shortest path from one location to another.
- E-Commerce: Online shopping sites use algorithms for product recommendations based on user behavior and preferences.
Data Structure এর ব্যবহার
Data Structures এবং Algorithms (DSA) সফটওয়্যার ডেভেলপমেন্টের প্রায় প্রতিটি ক্ষেত্রে মৌলিক ভূমিকা পালন করে:
- Operating Systems: হার্ডওয়্যার রিসোর্স পরিচালনা এবং অ্যাপ্লিকেশন সঞ্চালন নির্বিঘ্নে করার জন্য।
- Database Systems: Data দক্ষতার সাথে সংরক্ষণ, পুনরুদ্ধার, এবং পরিচালনা করার জন্য।
- Web Applications: ব্যবহারকারীর অনুরোধ এবং Data প্রক্রিয়াকরণ করার জন্য।
- Machine Learning: বড় Data সেট প্রক্রিয়া এবং মডেল প্রশিক্ষণ কার্যকরভাবে করার জন্য।
- Video Games: গেমের Logic, গ্রাফিক্স Rendering এবং রিয়েল-টাইম ব্যবহারকারীর ইন্টারঅ্যাকশন জন্য।
- Cryptography: Data সুরক্ষিত করার জন্য জটিল Encryption অ্যালগরিদমের মাধ্যমে।
- Data Analysis: বিশাল পরিমাণের Data বিশ্লেষণ এবং ব্যাখ্যা করার জন্য।
- Search Engines: ওয়েবসাইট ক্রল করা এবং দ্রুত প্রাসঙ্গিক Search ফলাফল সরবরাহ করার জন্য।
- Social Networks: ফেসবুকের মতো প্ল্যাটফর্মগুলি Data Structures ব্যবহার করে বন্ধুদের মধ্যে সংযোগ মডেল করতে।
- Navigation Systems: GPS অ্যাপস ব্যবহৃত সেরা পথ খুঁজে বের করার জন্য।
- E-Commerce: অনলাইন শপিং সাইটগুলি ব্যবহারকারীর আচরণ এবং পছন্দের ভিত্তিতে পণ্য সুপারিশ করার জন্য অ্যালগরিদম ব্যবহার করে।
The characteristics of a data structure include:
Correctness: This means the data structure works properly and gives the right results. It handles all situations correctly.
Time Complexity: This shows how fast the data structure can do its tasks. It tells us how much longer it takes when the data gets bigger.
Space Complexity: This means how much memory the data structure uses. Good data structures use less memory, which is important when memory is limited or the data is very large.
When choosing a data structure, it’s important to balance these features. A good data structure should be fast, accurate, and able to work well in different situations.
একটি Data Structure-এর বৈশিষ্ট্যগুলো হলো —
Correctness: Data Structure সব ধরনের পরিস্থিতিতে সঠিকভাবে কাজ করবে এবং সঠিক ফলাফল প্রদান করবে।
Time Complexity: Data Structure কত দ্রুত তার কাজ সম্পন্ন করতে পারে তা Time Complexity দ্বারা বোঝা যায়। Data-এর পরিমাণ বাড়তে থাকলে কোড execute হতে কত সময় লাগবে, সেটিও এটি নির্দেশ করে।
Space Complexity: একটি প্রোগ্রামে কতটা memory ব্যবহার হয় তা Space Complexity দ্বারা বোঝা যায়। ভালো Data Structure সাধারণত কম memory ব্যবহার করে, যা limited memory সিস্টেমে অনেক গুরুত্বপূর্ণ।
সঠিক Data Structure নির্বাচন করার সময় এই বৈশিষ্ট্যগুলো — Correctness, Time Complexity, এবং Space Complexity — এর মধ্যে ভারসাম্য রাখা প্রয়োজন। একটি ভালো Data Structure হওয়া উচিত দ্রুত, নির্ভুল, এবং বিভিন্ন পরিস্থিতিতে দক্ষভাবে কাজ করতে সক্ষম।
What is an Algorithm?
An algorithm is a step-by-step procedure or a set of instructions that are executed in a specific order to achieve a desired output. Algorithms are generally independent of any programming language, meaning they can be implemented in more than one programming language.
Criteria of an Algorithm:
An algorithm should have the following characteristics:
Unambiguous: Each step of the algorithm must be clear and unambiguous. Every step and its inputs/outputs should have only one meaning.
Input: An algorithm should have zero or more well-defined inputs.
Output: An algorithm should produce one or more well-defined outputs, which match the desired result.
Finiteness: An algorithm must terminate after a finite number of steps.
Feasibility: The algorithm should be feasible with the available resources.
Independent: The algorithm should be independent of programming code, providing step-by-step instructions.
Algorithm কী?
একটি algorithm হলো একটি step-by-step প্রক্রিয়া বা নির্দেশাবলির সেট যা একটি নির্দিষ্ট order-এ execute করা হয় যাতে একটি desired output অর্জন করা যায়। Algorithm সাধারণত যেকোনো programming language-এ স্বাধীন, অর্থাৎ এটি একাধিক programming language-এ implement করা যেতে পারে।
Algorithm-এর Criteria:
একটি algorithm-এর নিম্নলিখিত characteristics থাকা উচিত:
Unambiguous: algorithm-এর প্রতিটি step স্পষ্ট এবং unambiguous হওয়া উচিত। প্রতিটি step এবং এর inputs/outputs-এর একটি একক meaning থাকা উচিত।
Input: একটি algorithm-এ শূন্য বা একাধিক well-defined inputs থাকা উচিত।
Output: একটি algorithm-এ এক বা একাধিক well-defined outputs থাকা উচিত, যা desired result অনুযায়ী মিলবে।
Finiteness: একটি algorithm-কে একটি finite number of steps-এর মধ্যে terminate হতে হবে।
Feasibility: algorithmটি available resources-এর সাথে feasible হওয়া উচিত।
Independent: algorithmটি programming code-এর স্বাধীন হওয়া উচিত, এবং এটি step-by-step instructions প্রদান করতে হবে।
Previous Job Question Relational Algebra & SQL
- Given the following two tables (Students and Marks) in a database, write down the output of the given SQL queries and write down the SQL queries for the outputs:
i) SELECT Count (*) FROM Students S LEFT JOIN Marks M;
ii) SELECT StudentName From Students S JOIN Marks M ON S.Studentld = M.StudentId GROUP BY S.Studentld, S.StudentName HAVING SUM (Mark)>=200;
iii)List all the students name and number of subjects they have completed.
iv)List all the students who have not completed any subject.
v) List all the subject names.[Ministry of food, network/website Manager(ICT),2025] - DLD Qstn 2 CB, Officer (it), 2024


i) SELECT Count (*) FROM Students S LEFT JOIN Marks M;
ii) SELECT StudentName From Students S JOIN Marks M ON S.Studentld = M.StudentId GROUP BY S.Studentld, S.StudentName HAVING SUM (Mark)>=200;
iii)List all the students name and number of subjects they have completed.
iv)List all the students who have not completed any subject.
v) List all the subject names.