SlideShare a Scribd company logo
2
Most read
6
Most read
12
Most read
CURSOR IMPLEMENTATION

 Cursor implementation is nothing but the linked list representation using
array.

 Operations:

    • Initialization of array

    • Insertion: Insert new element at postion pointed by header(ZERO)
    and assign new position which is null to header.

    •Deletion: Delete an element and assign that position to header(ZERO)

    •Traversal: Display the entire array
CURSOR IMPLEMENTATION

     #include <iostream.h>
     #include <conio.h>

     #define SIZE 11

     struct node
     {
              char element;
              int nextpos;
     };
     typedef struct node cursor;

     cursor cursorspace[SIZE];
CURSOR IMPLEMENTATION
CURSOR IMPLEMENTATION
void intialize()
{
          for(int i=0;i<SIZE-1;i++)
          {          cursorspace[i].element = 'x';
                     cursorspace[i].nextpos = i+1;
          }
          cursorspace[SIZE-1].element = 'x';
          cursorspace[SIZE-1].nextpos = 0;
}
void display()
{
          cout<<"nCursor Implementation ";
          cout<<"n------------------------------------";
          cout<<"n"<<setw(6)<<"Slot"<<setw(12)<<"Element"<<setw(16)
                                                             <<"Next Position";
          for(int i=0;i<SIZE;i++)
          {          cout<<endl<<setw(4)<<i<<"            ";
                     cout<<cursorspace[i].element;
                     cout<<setw(15)<<cursorspace[i].nextpos;
                     cout<<endl;
          }
}
CURSOR IMPLEMENTATION

  Cursor Implementation
  ------------------------------------
    Slot Element Next Position
     0       x            1
     1       x            2
     2       x            3
     3       x            4
     4       x            5
     5       x            6
     6       x            7
     7       x            8
     8       x            9
     9       x           10
    10        x            0
CURSOR IMPLEMENTATION
void insert(char x)                                   Cursor Implementation
{                                                     ------------------------------------
         int tmp;                                       Slot Element Next Position
                                                         0       x            2
         tmp = cursoralloc();                            1       A             2
                                                         2       x            3
         if(tmp==0)                                      3       x            4
                  cout<<"nError-Outof space.";          4       x            5
         else                                            5       x            6
                  cursorspace[tmp].element = x;          6       x            7
                                                         7       x            8
}                                                        8       x            9
int cursoralloc()                                        9       x           10
{                                                       10        x            0
          int p;
          p = cursorspace[0].nextpos;
          cursorspace[0].nextpos = cursorspace[p].nextpos;
          return p;
}
CURSOR IMPLEMENTATION

Cursor Implementation                Cursor Implementation                Cursor Implementation
----------------------------------   ----------------------------------   ----------------------------------
  Slot Element Next                    Slot Element Next                    Slot Element Next

           Position                             Position                             Position
  0       x          2                 0       x          3                 0       x          6
  1       A          2                 1       A          2                 1       A          2
  2
  3
          x
          x
                     3
                     4
                                      2
                                       3
                                               B
                                               x
                                                          3
                                                          4
                                                                           2       B          3
                                                                            3       C          4
  4       x          5                 4       x          5                 4       D          5
  5       x          6                 5       x          6                 5       E          6
  6       x          7                 6       x          7                 6       x          7
  7       x          8                 7       x          8                 7       x          8
  8       x          9                 8       x          9                 8       x          9
  9       x         10                 9       x         10                 9       x         10
 10        x          0               10        x          0               10        x          0
CURSOR IMPLEMENTATION
void del(char x)
{
        int p,tmp;

        p = findprevious(x);

        if(p==0)
        {
                   tmp=1;
                   cursorfree(tmp);
        }
        else
        {
                   tmp = cursorspace[p].nextpos;
                   cursorspace[p].nextpos = cursorspace[tmp].nextpos;
                   cursorfree(tmp);
        }
}
CURSOR IMPLEMENTATION
int findprevious(char x)
{
         int p=0;
         if(cursorspace[1].element==x)
         {
                  return 0;
         }

        for(int i=0;x!=cursorspace[i].element;i++)
        {
                  p = cursorspace[i].nextpos;
        }//gives index of element to be deleted

        for(i=0;cursorspace[i].nextpos!=p;i++);

        p=i;//gives index of previous element
        return p;
}
CURSOR IMPLEMENTATION

void cursorfree(int p)
{
        for(int i=cursorspace[p].nextpos;i<SIZE-1;i++)
        {
                  if(cursorspace[i].nextpos==cursorspace[0].nextpos)
                  {
                           cursorspace[i].nextpos=p;
                           break;
                  }
        }
        cursorspace[p].nextpos = cursorspace[0].nextpos;
        cursorspace[p].element = 'x';
        cursorspace[0].nextpos = p;

}
CURSOR IMPLEMENTATION

Cursor Implementation                             Cursor Implementation
------------------------------------              ------------------------------------
  Slot Element Next Position                        Slot Element Next Position
   0       x            6                            0       x            4
   1       A             2                           1       A             2
   2       B             3                           2       B             3
   3       C             4
                                     Delete   D
                                                     3       C             5
   4       D             5                          4       x            6
   5       E             6                           5       E             4
   6       x            7                            6       x            7
   7       x            8                            7       x            8
   8       x            9                            8       x            9
   9       x           10                            9       x           10
  10        x            0                          10        x            0
CURSOR IMPLEMENTATION

Cursor Implementation                             Cursor Implementation
------------------------------------              ------------------------------------
  Slot Element Next Position                        Slot Element Next Position
   0       x            4                            0       x            3
   1       A             2                           1       A             2
   2       B             3                           2       B             5
   3       C             5
                                     Delete   C
                                                     3       x            4
   4       x            6                           4       x            6
   5       E             4                           5       E             3
   6       x            7                            6       x            7
   7       x            8                            7       x            8
   8       x            9                            8       x            9
   9       x           10                            9       x           10
  10        x            0                          10        x            0
Thank You

More Related Content

What's hot (20)

PPTX
Multithreading in java
Monika Mishra
 
PPTX
Mid point circle algorithm
Mani Kanth
 
PPTX
DataSructure-Time and Space Complexity.pptx
LakshmiSamivel
 
PPTX
Computer architecture data representation
Anil Pokhrel
 
PPTX
Line Drawing Algorithms - Computer Graphics - Notes
Omprakash Chauhan
 
PPT
Disk structure
Shareb Ismaeel
 
PPT
Microprogram Control
Anuj Modi
 
PPTX
Lecture 14 run time environment
Iffat Anjum
 
PPT
Data transfer and manipulation
Sanjeev Patel
 
PPTX
Graphics Primitives and CG Display Devices
DIPIKA83
 
PPTX
Instruction codes
pradeepa velmurugan
 
PPTX
Floating point representation
missstevenson01
 
PPTX
Instruction pipeline: Computer Architecture
InteX Research Lab
 
PPTX
Frame buffer
Aparna Joshi
 
PDF
Linked list implementation of Queue
Dr. Sindhia Lingaswamy
 
PPTX
Output primitives in Computer Graphics
Kamal Acharya
 
PPTX
Linked list
akshat360
 
PPTX
Memory Organization
Kamal Acharya
 
PPTX
Unit 4-booth algorithm
vishal choudhary
 
PDF
Python programming : Files
Emertxe Information Technologies Pvt Ltd
 
Multithreading in java
Monika Mishra
 
Mid point circle algorithm
Mani Kanth
 
DataSructure-Time and Space Complexity.pptx
LakshmiSamivel
 
Computer architecture data representation
Anil Pokhrel
 
Line Drawing Algorithms - Computer Graphics - Notes
Omprakash Chauhan
 
Disk structure
Shareb Ismaeel
 
Microprogram Control
Anuj Modi
 
Lecture 14 run time environment
Iffat Anjum
 
Data transfer and manipulation
Sanjeev Patel
 
Graphics Primitives and CG Display Devices
DIPIKA83
 
Instruction codes
pradeepa velmurugan
 
Floating point representation
missstevenson01
 
Instruction pipeline: Computer Architecture
InteX Research Lab
 
Frame buffer
Aparna Joshi
 
Linked list implementation of Queue
Dr. Sindhia Lingaswamy
 
Output primitives in Computer Graphics
Kamal Acharya
 
Linked list
akshat360
 
Memory Organization
Kamal Acharya
 
Unit 4-booth algorithm
vishal choudhary
 
Python programming : Files
Emertxe Information Technologies Pvt Ltd
 

Viewers also liked (9)

PPT
Data structures & algorithms lecture 3
Poojith Chowdhary
 
PDF
Db2 For I Parallel Data Load
Thomas Wolfe
 
PPTX
Cause effect sentences and exercises 2011 a
BETO MG
 
PPT
Connectors: cause and result
f2teacher
 
PPT
Introduction of ISPF
Anil Bharti
 
DOC
DB2 utilities
Udayakumar Suseendran
 
PDF
Stored-Procedures-Presentation
Chuck Walker
 
DOC
De lab manual
Naga Rajan
 
PDF
Ibm db2 interview questions and answers
Sweta Singh
 
Data structures & algorithms lecture 3
Poojith Chowdhary
 
Db2 For I Parallel Data Load
Thomas Wolfe
 
Cause effect sentences and exercises 2011 a
BETO MG
 
Connectors: cause and result
f2teacher
 
Introduction of ISPF
Anil Bharti
 
DB2 utilities
Udayakumar Suseendran
 
Stored-Procedures-Presentation
Chuck Walker
 
De lab manual
Naga Rajan
 
Ibm db2 interview questions and answers
Sweta Singh
 
Ad

Similar to Cursor implementation (20)

PPTX
Data structures
Pranav Gupta
 
PDF
Arrays
Learn By Watch
 
PDF
7. arrays
웅식 전
 
PDF
Plc (1)
James Croft
 
PDF
Notes
Hitesh Wagle
 
PDF
Array notes
Hitesh Wagle
 
PPT
Cmp104 lec 2 number system
kapil078
 
PPTX
Set data structure 2
Tech_MX
 
PPTX
AA-sort with SSE4.1
MITSUNARI Shigeo
 
PDF
8th Alg - L6.6--Jan26
jdurst65
 
PDF
VTU DSA Lab Manual
AkhilaaReddy
 
PDF
DSA UNIT II ARRAY AND LIST - notes
swathirajstar
 
PPTX
Class list data structure
Katang Isip
 
PPT
Arrays
archikabhatia
 
DOCX
บทที่4
น้ำฝน ทองคำ
 
PPTX
ตัวแปรชุดและตัวแปรกลุ่มอักขระ
Jiraporn Chaijaroen
 
PPT
Arrays and structures
Mohd Arif
 
PPTX
ตัวแปรชุดและตัวแปรกลุ่มอักขระ
Jiraporn Chaijaroen
 
PPT
Ch1 2
Teksify
 
PPT
2DArrays.ppt
Nooryaseen9
 
Data structures
Pranav Gupta
 
7. arrays
웅식 전
 
Plc (1)
James Croft
 
Array notes
Hitesh Wagle
 
Cmp104 lec 2 number system
kapil078
 
Set data structure 2
Tech_MX
 
AA-sort with SSE4.1
MITSUNARI Shigeo
 
8th Alg - L6.6--Jan26
jdurst65
 
VTU DSA Lab Manual
AkhilaaReddy
 
DSA UNIT II ARRAY AND LIST - notes
swathirajstar
 
Class list data structure
Katang Isip
 
ตัวแปรชุดและตัวแปรกลุ่มอักขระ
Jiraporn Chaijaroen
 
Arrays and structures
Mohd Arif
 
ตัวแปรชุดและตัวแปรกลุ่มอักขระ
Jiraporn Chaijaroen
 
Ch1 2
Teksify
 
2DArrays.ppt
Nooryaseen9
 
Ad

Recently uploaded (20)

PDF
Find the Latest Government Jobs in One Click – Stay Updated with Daily Notifi...
Reeshna Prajeesh
 
PPT
SQL.pptkarim pfe rabatkarim pfe rabatkarim pfe rabat
Keeyvikyv
 
PPTX
Plant Growth and Development-Part I, ppt.pptx
7300511143
 
PDF
hr generalist training.pdf..............
a25075044
 
PPTX
Learn AI in Software Testing - Venkatesh (Rahul Shetty)
Venkatesh (Rahul Shetty)
 
PPTX
21st-Literature.pptxjsududhshsusushshsusuhsgsysh
JohnVJLBellen
 
PPTX
STATE OFFICERS for organization reference
conqueror3rd
 
PDF
165. Reviewer Certificate in Physical Science
Manu Mitra
 
PPTX
文凭复刻澳洲电子毕业证阳光海岸大学成绩单USC录取通知书
Taqyea
 
PDF
Bilal Ibrar | Digital Marketing Expert | Resume | CV
Bilal Ibrar
 
PDF
From-Idea-to-Business-Plan-A-Practical-Guide.pdf
eman youssif
 
PPTX
5G Model Site PPT WBA179_ROB_Ghorai (1).pptx
kousikmaity15
 
PDF
Rediscovering Classic Illustration Techniques.pdf
Bruno Amezcua
 
PDF
NotificationForTheTeachingPositionsAdvt012025.pdf
sunitsaathi
 
PDF
Web Developer Jobs in Jaipur Your Gateway to a Thriving Tech Career in Rajast...
vinay salarite
 
DOCX
PMCF -Performance Monitoring and Coaching Form
ROSALIESOMBILON
 
PDF
reStartEvents July 10th TS:SCI & Above Employer Directory.pdf
Ken Fuller
 
PPTX
Future_Proofing_Your_Career_25_Essential_Skills_for_2025.pptx
presentifyai
 
PPTX
Web Developer Jobs in Jaipur Your Gateway to a Thriving Tech Career in Rajast...
vinay salarite
 
DOCX
PMCF (Performance Monitoring and Coaching Form
ROSALIESOMBILON
 
Find the Latest Government Jobs in One Click – Stay Updated with Daily Notifi...
Reeshna Prajeesh
 
SQL.pptkarim pfe rabatkarim pfe rabatkarim pfe rabat
Keeyvikyv
 
Plant Growth and Development-Part I, ppt.pptx
7300511143
 
hr generalist training.pdf..............
a25075044
 
Learn AI in Software Testing - Venkatesh (Rahul Shetty)
Venkatesh (Rahul Shetty)
 
21st-Literature.pptxjsududhshsusushshsusuhsgsysh
JohnVJLBellen
 
STATE OFFICERS for organization reference
conqueror3rd
 
165. Reviewer Certificate in Physical Science
Manu Mitra
 
文凭复刻澳洲电子毕业证阳光海岸大学成绩单USC录取通知书
Taqyea
 
Bilal Ibrar | Digital Marketing Expert | Resume | CV
Bilal Ibrar
 
From-Idea-to-Business-Plan-A-Practical-Guide.pdf
eman youssif
 
5G Model Site PPT WBA179_ROB_Ghorai (1).pptx
kousikmaity15
 
Rediscovering Classic Illustration Techniques.pdf
Bruno Amezcua
 
NotificationForTheTeachingPositionsAdvt012025.pdf
sunitsaathi
 
Web Developer Jobs in Jaipur Your Gateway to a Thriving Tech Career in Rajast...
vinay salarite
 
PMCF -Performance Monitoring and Coaching Form
ROSALIESOMBILON
 
reStartEvents July 10th TS:SCI & Above Employer Directory.pdf
Ken Fuller
 
Future_Proofing_Your_Career_25_Essential_Skills_for_2025.pptx
presentifyai
 
Web Developer Jobs in Jaipur Your Gateway to a Thriving Tech Career in Rajast...
vinay salarite
 
PMCF (Performance Monitoring and Coaching Form
ROSALIESOMBILON
 

Cursor implementation

  • 1. CURSOR IMPLEMENTATION  Cursor implementation is nothing but the linked list representation using array.  Operations: • Initialization of array • Insertion: Insert new element at postion pointed by header(ZERO) and assign new position which is null to header. •Deletion: Delete an element and assign that position to header(ZERO) •Traversal: Display the entire array
  • 2. CURSOR IMPLEMENTATION #include <iostream.h> #include <conio.h> #define SIZE 11 struct node { char element; int nextpos; }; typedef struct node cursor; cursor cursorspace[SIZE];
  • 4. CURSOR IMPLEMENTATION void intialize() { for(int i=0;i<SIZE-1;i++) { cursorspace[i].element = 'x'; cursorspace[i].nextpos = i+1; } cursorspace[SIZE-1].element = 'x'; cursorspace[SIZE-1].nextpos = 0; } void display() { cout<<"nCursor Implementation "; cout<<"n------------------------------------"; cout<<"n"<<setw(6)<<"Slot"<<setw(12)<<"Element"<<setw(16) <<"Next Position"; for(int i=0;i<SIZE;i++) { cout<<endl<<setw(4)<<i<<" "; cout<<cursorspace[i].element; cout<<setw(15)<<cursorspace[i].nextpos; cout<<endl; } }
  • 5. CURSOR IMPLEMENTATION Cursor Implementation ------------------------------------ Slot Element Next Position 0 x 1 1 x 2 2 x 3 3 x 4 4 x 5 5 x 6 6 x 7 7 x 8 8 x 9 9 x 10 10 x 0
  • 6. CURSOR IMPLEMENTATION void insert(char x) Cursor Implementation { ------------------------------------ int tmp; Slot Element Next Position 0 x 2 tmp = cursoralloc(); 1 A 2 2 x 3 if(tmp==0) 3 x 4 cout<<"nError-Outof space."; 4 x 5 else 5 x 6 cursorspace[tmp].element = x; 6 x 7 7 x 8 } 8 x 9 int cursoralloc() 9 x 10 { 10 x 0 int p; p = cursorspace[0].nextpos; cursorspace[0].nextpos = cursorspace[p].nextpos; return p; }
  • 7. CURSOR IMPLEMENTATION Cursor Implementation Cursor Implementation Cursor Implementation ---------------------------------- ---------------------------------- ---------------------------------- Slot Element Next Slot Element Next Slot Element Next Position Position Position 0 x 2 0 x 3 0 x 6 1 A 2 1 A 2 1 A 2 2 3 x x 3 4  2 3 B x 3 4  2 B 3 3 C 4 4 x 5 4 x 5 4 D 5 5 x 6 5 x 6 5 E 6 6 x 7 6 x 7 6 x 7 7 x 8 7 x 8 7 x 8 8 x 9 8 x 9 8 x 9 9 x 10 9 x 10 9 x 10 10 x 0 10 x 0 10 x 0
  • 8. CURSOR IMPLEMENTATION void del(char x) { int p,tmp; p = findprevious(x); if(p==0) { tmp=1; cursorfree(tmp); } else { tmp = cursorspace[p].nextpos; cursorspace[p].nextpos = cursorspace[tmp].nextpos; cursorfree(tmp); } }
  • 9. CURSOR IMPLEMENTATION int findprevious(char x) { int p=0; if(cursorspace[1].element==x) { return 0; } for(int i=0;x!=cursorspace[i].element;i++) { p = cursorspace[i].nextpos; }//gives index of element to be deleted for(i=0;cursorspace[i].nextpos!=p;i++); p=i;//gives index of previous element return p; }
  • 10. CURSOR IMPLEMENTATION void cursorfree(int p) { for(int i=cursorspace[p].nextpos;i<SIZE-1;i++) { if(cursorspace[i].nextpos==cursorspace[0].nextpos) { cursorspace[i].nextpos=p; break; } } cursorspace[p].nextpos = cursorspace[0].nextpos; cursorspace[p].element = 'x'; cursorspace[0].nextpos = p; }
  • 11. CURSOR IMPLEMENTATION Cursor Implementation Cursor Implementation ------------------------------------ ------------------------------------ Slot Element Next Position Slot Element Next Position 0 x 6 0 x 4 1 A 2 1 A 2 2 B 3 2 B 3 3 C 4 Delete D 3 C 5 4 D 5  4 x 6 5 E 6 5 E 4 6 x 7 6 x 7 7 x 8 7 x 8 8 x 9 8 x 9 9 x 10 9 x 10 10 x 0 10 x 0
  • 12. CURSOR IMPLEMENTATION Cursor Implementation Cursor Implementation ------------------------------------ ------------------------------------ Slot Element Next Position Slot Element Next Position 0 x 4 0 x 3 1 A 2 1 A 2 2 B 3 2 B 5 3 C 5 Delete C 3 x 4 4 x 6  4 x 6 5 E 4 5 E 3 6 x 7 6 x 7 7 x 8 7 x 8 8 x 9 8 x 9 9 x 10 9 x 10 10 x 0 10 x 0