Mechatronics geek blog

المواضيع الرئيسيه للميكاترونكس

Physical System Modeling , Sensors and Actuators ,Signals and Systems , Computers and Logic Systems AND Software and Data Acquisition

أردوينو

شرح للأردوينو يأخذك من مستوي المبتديء إلي المحترف

لغات البرمجه

C ,C++ ,C# ,Python ,Java ...

الانظمه المدمجه

AVR,PIC, ARM CORTEX ..., RTOS, Automotive Protocoles ( CAN - LIN - ...)

Solid Works

العديد من شروحات السوليد وركس تأخذك من مستوي المبتديء إلي مستوي المحترف

Sunday, May 5, 2019

Data Structure

Data Structure main topics:
----------------------------------
Linked List
Stack
Queue
Tree
--------------------------------------------------------------------------------------------------------
Array: is the best data structure in terms of accessing time as the time complexity of it is O(1) the time required to access any element of it is constant. Problem: Memory usage!

Linked List: 
is the best data structure in terms of memory management but in terms of accessing time is O(N). Problem: Accessing time- Time complexity is O(N)!

Types:
          - Simply Linked List.
          - Doubly Linked List.

-------------------------------------------------------------------
Key Word to implement linked list is to draw it.
--------------------------------------------------------------------
Note:
Each node in the linked list should be similar to all o them. As the struct (Node) is considered as a user-defined data type so each structure is a data type defined by the number and the type of its members. So we can not change the node structure as that means change the type of the pointer used within the node to point to the next node and the previous one.



=======================================================
Stack (Last In First Out (LIFO)):
--------------------------------------------
* Push in Stack
             - Before pushing data we should make sure the stack is not full.
*Pop from Stack
             - Before popping from the stack we should make sure that the stack is not empty.

Stack use case:-
---------------------
We can mirror a string by pushing it in a stack then popping it again.

3 Elements For the Stack:
----------------------------------
- Pointer to the Top of Stack (TOS)
- Store Stack Size
- Store Data in Stack

So we need to implement Stack as :

typedef struct stack
{
       int *stkTos; /*Pointer to the top of the Stack*/
       int tos;  /**/
      int size;  /**/
}stack;

________________________________________________________________________