West Zone Power Distribution Company Limited(WZPDCL)
Post: Assistant Engineer (CSE)
Exam Date: 27.05.2023
A binary tree is a hierarchical data structure in which each node has at most two children, referred to as the left child and the right child. It is widely used in computer science for tasks such as searching, sorting, and hierarchical representation of data.
Structure of a Binary Tree
- Root: The topmost node of the tree.
- Parent Node: A node with child nodes.
- Child Node: Nodes directly connected to another node.
- Leaf Node: Nodes with no children.
- Height: The number of edges from the root to the deepest leaf.
Types of Binary Trees
- Full Binary Tree: Every node has either 0 or 2 children.
- Complete Binary Tree: All levels are fully filled except possibly the last, which is filled from left to right.
- Perfect Binary Tree: All internal nodes have two children, and all leaf nodes are at the same level.
Example of a Binary Tree
10
/ \
5 20
/ \ / \
3 7 15 25
Explanation:
- Root Node: 10
- Children of 10: 5 (left child) and 20 (right child)
- Leaf Nodes: 3, 7, 15, 25 (no children)
- Parent Node: 10 is the parent of 5 and 20; 5 is the parent of 3 and 7.
- Height: The height of the tree is 2 (edges from 10 to the deepest leaf).
Binary Tree Applications
- Searching and Sorting: Binary Search Tree (BST).
- Expression Parsing: Abstract Syntax Trees in compilers.
- Networking: Routing and hierarchical structure representation.
Pre-order is a tree traversal method where nodes are processed in the following order:
- Root
- Left Subtree
- Right Subtree
Post-order is a tree traversal method where nodes are processed in the following order:
- Left Subtree
- Right Subtree
- Root
Difference between Primary Key and Foreign Key
- Primary Key: Uniquely identifies each record in a table and cannot contain NULL values.
- Foreign Key: Refers to a primary key in another table to create a relationship between tables.
- Uniqueness: Primary key must be unique; Foreign key can have duplicate values.
- Null Values: Primary key cannot be NULL; Foreign key may contain NULL values.
A trigger is a database object that automatically executes when certain events occur on a table, such as INSERT, UPDATE, or DELETE.
- Automatic Execution: It runs automatically when a specified event occurs.
- Purpose: Used to maintain data integrity and enforce business rules.
- Example: Automatically updating another table or logging changes after data modification.
Primary Key এবং Foreign Key-এর পার্থক্য
- Primary Key: এটি table-এর প্রতিটি record-কে uniquely identify করে এবং NULL value থাকতে পারে না।
- Foreign Key: এটি অন্য table-এর primary key-কে refer করে এবং table-এর মধ্যে relationship তৈরি করে।
- Uniqueness: Primary key সবসময় unique হয়; Foreign key duplicate হতে পারে।
- Null Values: Primary key NULL হতে পারে না; Foreign key NULL থাকতে পারে।
Trigger হলো একটি database object যা কোনো table-এ INSERT, UPDATE বা DELETE ঘটলে স্বয়ংক্রিয়ভাবে execute হয়।
- Automatic Execution: নির্দিষ্ট event ঘটলে এটি নিজে থেকেই run হয়।
- Purpose: Data integrity বজায় রাখা এবং business rule enforce করার জন্য ব্যবহৃত হয়।
- Example: Data পরিবর্তনের পরে automatically log update করা বা অন্য table update করা।
MVC is a software design pattern used to separate an application into three main components: Model, View, and Controller.
MVC Design Pattern Components
- Model: Represents the data and business logic of the application. It handles data processing and interacts with the database.
- View: Responsible for the user interface. It displays the data from the model to the user.
- Controller: Acts as an intermediary between Model and View. It receives user input, processes it, and updates the Model and View accordingly.
Working of MVC
- User interacts with the View.
- The Controller processes the input.
- The Model updates the data.
- The updated data is shown again in the View.
MVC হলো একটি software design pattern যা একটি application-কে তিনটি প্রধান অংশে ভাগ করে: Model, View এবং Controller।
MVC Design Pattern-এর অংশসমূহ
- Model: এটি application-এর data এবং business logic পরিচালনা করে এবং database-এর সাথে কাজ করে।
- View: এটি user interface প্রদর্শন করে এবং Model-এর data user-কে দেখায়।
- Controller: এটি Model এবং View-এর মধ্যে মধ্যস্থতাকারী হিসেবে কাজ করে। এটি user input গ্রহণ করে এবং Model ও View update করে।
MVC-এর কাজের ধাপ
- User View-এর সাথে interaction করে।
- Controller input process করে।
- Model data update করে।
- Update হওয়া data আবার View-এ প্রদর্শিত হয়।

Some common architectural design patterns:
• Layered Architecture (n-tier)
• Client-Server Architecture
• Model-View-Controller (MVC)
• Microservices Architecture
• Event-Driven Architecture
• Service-Oriented Architecture (SOA)
• Pipe and Filter Architecture
• Master-Slave Architecture
• Peer-to-Peer (P2P) Architecture
• Broker Architecture
