Back
  • Qissba
  • Courses

      CBSE Class 12

      PYTHON

      Computer Science

      • Python
      • Computer System Overview
      • Computer Networks
      • society Law & Ethics
      • Data Representation
      • Boolean Logics
      Python Online Free Courses for Classes 11th and 12th
  • Blog
  • Shop
    • Cart
    • Checkout
    • My account
  • About Us
  • Contact
  • Career
Have any question?
(+91) 09897990175
qissba@gmail.com
RegisterLogin
Qissba
  • Qissba
  • Courses

      CBSE Class 12

      PYTHON

      Computer Science

      • Python
      • Computer System Overview
      • Computer Networks
      • society Law & Ethics
      • Data Representation
      • Boolean Logics
      Python Online Free Courses for Classes 11th and 12th
  • Blog
  • Shop
    • Cart
    • Checkout
    • My account
  • About Us
  • Contact
  • Career

    Computer Science

    data-structures-in-python-stack-and- queue-using-lists

    Data Structures in Python | CBSE Class 12

    • Posted by Kabeer Sahib
    • Categories Computer Science

    In this section of “Data Structure in Python | Stack and Queue Using Lists“, we will provide a comprehensive information about all concepts of  Data Structures in Python like Stack and Queue Using Lists with examples including

    Table of Contents

    Toggle
    • INTRODUCTION TO DATA STRUCTURES
    • ELEMENTARY DATA REPRESENTATION IN PYTHON
      • Data Type vs. Data Structure in python
    • Different Data Structures in python
      • Simple Data Structures in python.
      • Compound Data Structures in python.
      • Linear Lists Arrays
      • Stacks
      • Queues
      • Linked lists
      • Trees
    • Operations on Data structures
    • Elementary Data Representation in Python.
    • Data Type Vs Data Structure in python.
    • Different Types of Data Structure in python.

    and much more, nearly all information about Data Structure in Python which is necessary to become a python Developer / Programmer.

    Surely, by the end of this tutorial, you will have a solid understanding of all about available Data Structure in Python and will be able to use this knowledge in their own programming projects.

    Also this tutorial covers all necessary topics/concepts required to complete your exams preparations in CBSE schools / classes 11th and 12th in 2023 – 2024.

    INTRODUCTION TO DATA STRUCTURES

    The computer system is used essentially as data manipulation system where “Data’ are very important thing for it. The data can be referred to  in many ways viz. data, data items, data structures etc. The data being an active participant in the organizations’ operations and Planning, data are aggregated and summarized in various meaningful ways to form information. The data must be represented, stored, organized, processed and managed so as to support the user environment. All these factors very much depend upon the way data are aggregated. The Data structures are an effective and reliable way to achieve this.

    We are going to introduces data structures, basic terminology used for them, and different commonly used data structures and also be discussing about Stacks and Queues data structures.

     

    ELEMENTARY DATA REPRESENTATION IN PYTHON

     Elementary representation of data can be in forms of raw data, data item, data structures.

    • Raw data are raw facts. These are simply values or set of values.
    • Data items are used as per their associated data types

    Data items are used as per their associated data types.

    While designing data structures, one must determine the logical picture of the data in a particular program, choose the representation of the data, and develop the operations that will be applied on.

    Data Type vs. Data Structure in python

    In python A Data type defines a set of values along with well-defined operations stating its input-output behavior for example, you cannot put decimal point in an integer or two strings cannot not be multiplied etc.

    Data structure in python, On the other hand, is a physical implementation that clearly defines a way of  storing, accessing, manipulating data stored in a data structure. The data stored in a data structure has a specific work pattern e.g., in a stack, all insertions and deletions take place at one and only.

    For example, Python supports lists as a collection data type which can store heterogenous types of elements, but when we implement List as a data structure, its behavior is clearly a redecided for example, it will store all elements of same type; for searching, list elements will be presorted and so forth.

     

    Different Data Structures in python

    Data Structures are very important in a computer system, as these not only allow the user to combine various data types in a group but also allow processing of the group as a single unit thereby making things much simpler and easier. The data structures can be classified into following two types:

    1. Simple Data Structures in python.

    These data structures are normally built from primitive data types like integers, reals, characters, boolean. Following data structures can be termed as simple data structures:

    • Array or Linear Lists

    1. Compound Data Structures in python.

    Simple data structures can be combined in various ways to form more complex structures called compound data structures. Compound data structures are classified into following two types:

    • Linear data structures.

    These data structures are single level data structures. A data structure is said to be linear if its elements form a sequence. Following are the examples of linear data structures

     (a) Stack

     (b) Queue  

     (c) Linked List

     

    • Non-Linear data structures.

    These are multilevel data structures. Example of non-linear data structure is Tree.

    Below given figure shows, all the data structures.

    different-types-of-data-structures

    Linear Lists Arrays

    Linear Lists or Arrays refer to a named list of a finite number n of similar data elements. Each of the data elements can be referenced respectively by a set of consecutive numbers, usually 0, 1, 2, 3….n. If the name of a linear list of 10 elements is LIL, then its elements will be referenced as shown:

      LIL[0], LIL[1], LIL[2], LIL[3], … LIL[91

     Arrays can be one dimensional, two dimensional or multi-dimensional. In Python, arrays are implemented through List data types as Linear Lists or through NumPy arrays.

     

    Stacks

    Stacks data structures refer to the lists stored and accessed in a special way, where LIFO (Last In First Out) technique is followed. In Stacks, insertions and deletions take place only at one end, called the top. Stack is similar to a stack of plates as shown in Fig. 9.2(a). Note that plates are inserted or removed only from the top of the stack.

     

    Stack-data-structure-python

    Queues

    Queues data structures are FIFO (First in First Out) lists, where insertions take place at the “rear” end of the queues and deletions take place at the “front” end of the queues. Queue is much the same as a line of people [shown in Figure] waiting for their turn to vote. First person will be the first to vote and a new person can join the queue, at the rear-end of it.

    Queue-in-python

    Linked lists

    Linked lists are special lists of some data elements linked to one another. The logical ordering is represented by having each element pointing to the next element. Each element is called a node, which has two parts. The INFO part which stores the information and the reference-pointer part, which points to i.e., stores the reference of the next element. Below given figure shows both types of lists (singly linked lists and doubly linked lists).

    linked-lists-in-python

    In singly linked lists, nodes have one reference-pointer(next) pointing to the next node, whereas nodes of doubly linked lists have two reference-pointers (prev and next). Prev points to the previous node and next points to the next node in the list.

     

    Trees

    Trees are multilevel data structures having a hierarchical relationship among its elements called nodes. Topmost node is called the root of the tree and bottommost nodes are called leaves of the tree. Each of the nodes has some reference-pointers, pointing to (i.e., storing the reference of) the nodes below it.

    trees-in-python

     

     

    Operations on Data structures

    The basic operations that re performed on data structures are as follows:

    1. Insertion. Insertion means addition of a new data element in a data structure.
    2. Deletion means removal of a data element from a data structure. The data element is searched for before its removal.
    3. Searching. Searching involves searching for the specified daa element in a data structure.
    4. Traversal of data structure means processing all the data elements of it, one by one.
    5. Sorting. Arranging data elements of a data structure in a specified order is called sorting.
    6. Merging. Combining elements of two similar data structures to form a new data structure of same type, is called merging.

     

     

     

    qissba-free-python-courses-for-cbse-computer-science

    • Share:
    Kabeer Sahib

    A Trained Post Graduate Teacher with 10 years of experience and working as TGT/PGT–Computer Science including good Management and administration skills with managerial positions in previous work environments

    Previous post

    String in Python | String Handling | CBSE | Class 12
    22 June 2023

    Next post

    Digital Modulation in Computer Networks | CBSE Class 12
    26 June 2023

    You may also like

    Operator Precedence & Associativity in Python | CBSE Class 11| Computer Science
    24 June 2025

    Dear Class 11th STUDENTS, ! Welcome to this tutorial of Operators in Python from your CBSE class 11 of …

    basics-of-python-programming-languages-cbse-class-11
    Basics of Python Programming Language | CBSE Class 11| Computer Science
    3 June 2025
    encoding-schemes-cbse-class-11-computer-science
    Encoding Schemes | ASCII | ISCII | Unicode | CBSE Class 11| Computer Science
    21 May 2025

    Leave A Reply Cancel reply

    You must be logged in to post a comment.

    Search

    Categories

    • Computer Science
    • Education
    • Education News
    Computer Science : Python – CBSE Class 11

    Computer Science : Python – CBSE Class 11

    ₹1,999.00Free
    Computer Science : System Overview – CBSE Class 11

    Computer Science : System Overview – CBSE Class 11

    ₹999.00Free
    Computer Science : Python – CBSE Class 12

    Computer Science : Python – CBSE Class 12

    ₹1,999.00Free

    Login with your site account

    Lost your password?

    Not a member yet? Register now

    Log in

    Copyright @ 2021 ! QISSBA EDUCATION ! .

    • Privacy
    • Terms
    • Sitemap
    • About Us

    Login with your site account

    Lost your password?

    Not a member yet? Register now

    Register a new account

    Are you a member? Login now