SlideShare a Scribd company logo
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

List in Python
List in PythonList in Python
List in Python
Siddique Ibrahim
 
Queue in Data Structure
Queue in Data Structure Queue in Data Structure
Queue in Data Structure
Janki Shah
 
Data types in java
Data types in javaData types in java
Data types in java
HarshitaAshwani
 
Structure in C
Structure in CStructure in C
Structure in C
Kamal Acharya
 
Programming in c Arrays
Programming in c ArraysProgramming in c Arrays
Programming in c Arrays
janani thirupathi
 
stack presentation
stack presentationstack presentation
Super keyword in java
Super keyword in javaSuper keyword in java
Super keyword in java
Hitesh Kumar
 
Unit 1 introduction to data structure
Unit 1   introduction to data structureUnit 1   introduction to data structure
Unit 1 introduction to data structure
kalyanineve
 
Functions in python slide share
Functions in python slide shareFunctions in python slide share
Functions in python slide share
Devashish Kumar
 
Python programming : Classes objects
Python programming : Classes objectsPython programming : Classes objects
Python programming : Classes objects
Emertxe Information Technologies Pvt Ltd
 
Method overloading and constructor overloading in java
Method overloading and constructor overloading in javaMethod overloading and constructor overloading in java
Method overloading and constructor overloading in java
baabtra.com - No. 1 supplier of quality freshers
 
Stack
StackStack
Data Structures in Python
Data Structures in PythonData Structures in Python
Data Structures in Python
Devashish Kumar
 
Arrays and structures
Arrays and structuresArrays and structures
Arrays and structuresMohd Arif
 
Array in c
Array in cArray in c
Array in c
Ravi Gelani
 
Python list
Python listPython list
Python list
Mohammed Sikander
 
Presentation on array
Presentation on array Presentation on array
Presentation on array
topu93
 
Data Structure (Queue)
Data Structure (Queue)Data Structure (Queue)
Data Structure (Queue)
Adam Mukharil Bachtiar
 
Static keyword ppt
Static keyword pptStatic keyword ppt
Static keyword ppt
Vinod Kumar
 
Array in c programming
Array in c programmingArray in c programming
Array in c programming
Mazharul Islam
 

What's hot (20)

List in Python
List in PythonList in Python
List in Python
 
Queue in Data Structure
Queue in Data Structure Queue in Data Structure
Queue in Data Structure
 
Data types in java
Data types in javaData types in java
Data types in java
 
Structure in C
Structure in CStructure in C
Structure in C
 
Programming in c Arrays
Programming in c ArraysProgramming in c Arrays
Programming in c Arrays
 
stack presentation
stack presentationstack presentation
stack presentation
 
Super keyword in java
Super keyword in javaSuper keyword in java
Super keyword in java
 
Unit 1 introduction to data structure
Unit 1   introduction to data structureUnit 1   introduction to data structure
Unit 1 introduction to data structure
 
Functions in python slide share
Functions in python slide shareFunctions in python slide share
Functions in python slide share
 
Python programming : Classes objects
Python programming : Classes objectsPython programming : Classes objects
Python programming : Classes objects
 
Method overloading and constructor overloading in java
Method overloading and constructor overloading in javaMethod overloading and constructor overloading in java
Method overloading and constructor overloading in java
 
Stack
StackStack
Stack
 
Data Structures in Python
Data Structures in PythonData Structures in Python
Data Structures in Python
 
Arrays and structures
Arrays and structuresArrays and structures
Arrays and structures
 
Array in c
Array in cArray in c
Array in c
 
Python list
Python listPython list
Python list
 
Presentation on array
Presentation on array Presentation on array
Presentation on array
 
Data Structure (Queue)
Data Structure (Queue)Data Structure (Queue)
Data Structure (Queue)
 
Static keyword ppt
Static keyword pptStatic keyword ppt
Static keyword ppt
 
Array in c programming
Array in c programmingArray in c programming
Array in c programming
 

Viewers also liked

Data structures & algorithms lecture 3
Data structures & algorithms lecture 3Data structures & algorithms lecture 3
Data structures & algorithms lecture 3
Poojith Chowdhary
 
Db2 For I Parallel Data Load
Db2 For I Parallel Data LoadDb2 For I Parallel Data Load
Db2 For I Parallel Data Load
Thomas Wolfe
 
Cause effect sentences and exercises 2011 a
Cause effect sentences and exercises 2011   aCause effect sentences and exercises 2011   a
Cause effect sentences and exercises 2011 aBETO MG
 
Connectors: cause and result
Connectors: cause and resultConnectors: cause and result
Connectors: cause and result
f2teacher
 
Introduction of ISPF
Introduction of ISPFIntroduction of ISPF
Introduction of ISPF
Anil Bharti
 
DB2 utilities
DB2 utilitiesDB2 utilities
DB2 utilities
Udayakumar Suseendran
 
Stored-Procedures-Presentation
Stored-Procedures-PresentationStored-Procedures-Presentation
Stored-Procedures-PresentationChuck Walker
 
Linked list
Linked listLinked list
Linked list
akshat360
 
Ibm db2 interview questions and answers
Ibm db2 interview questions and answersIbm db2 interview questions and answers
Ibm db2 interview questions and answersSweta Singh
 

Viewers also liked (10)

Data structures & algorithms lecture 3
Data structures & algorithms lecture 3Data structures & algorithms lecture 3
Data structures & algorithms lecture 3
 
Db2 For I Parallel Data Load
Db2 For I Parallel Data LoadDb2 For I Parallel Data Load
Db2 For I Parallel Data Load
 
Cause effect sentences and exercises 2011 a
Cause effect sentences and exercises 2011   aCause effect sentences and exercises 2011   a
Cause effect sentences and exercises 2011 a
 
Connectors: cause and result
Connectors: cause and resultConnectors: cause and result
Connectors: cause and result
 
Introduction of ISPF
Introduction of ISPFIntroduction of ISPF
Introduction of ISPF
 
DB2 utilities
DB2 utilitiesDB2 utilities
DB2 utilities
 
Stored-Procedures-Presentation
Stored-Procedures-PresentationStored-Procedures-Presentation
Stored-Procedures-Presentation
 
De lab manual
De lab manualDe lab manual
De lab manual
 
Linked list
Linked listLinked list
Linked list
 
Ibm db2 interview questions and answers
Ibm db2 interview questions and answersIbm db2 interview questions and answers
Ibm db2 interview questions and answers
 

Similar to Cursor implementation

20110424 action scriptを使わないflash勉強会
20110424 action scriptを使わないflash勉強会20110424 action scriptを使わないflash勉強会
20110424 action scriptを使わないflash勉強会Hiroki Mizuno
 
Sparse Matrix and Polynomial
Sparse Matrix and PolynomialSparse Matrix and Polynomial
Sparse Matrix and Polynomial
Aroosa Rajput
 
Haskellで学ぶ関数型言語
Haskellで学ぶ関数型言語Haskellで学ぶ関数型言語
Haskellで学ぶ関数型言語
ikdysfm
 
The Groovy Puzzlers – The Complete 01 and 02 Seasons
The Groovy Puzzlers – The Complete 01 and 02 SeasonsThe Groovy Puzzlers – The Complete 01 and 02 Seasons
The Groovy Puzzlers – The Complete 01 and 02 Seasons
Baruch Sadogursky
 
Clase de matlab
Clase de matlabClase de matlab
Clase de matlabDeyBarreto
 
INTRODUCTION TO MATLAB presentation.pptx
INTRODUCTION TO MATLAB presentation.pptxINTRODUCTION TO MATLAB presentation.pptx
INTRODUCTION TO MATLAB presentation.pptx
Devaraj Chilakala
 
Functional Programming In Mathematica
Functional Programming In MathematicaFunctional Programming In Mathematica
Functional Programming In Mathematica
Hossam Karim
 
Prob-Dist-Toll-Forecast-Uncertainty
Prob-Dist-Toll-Forecast-UncertaintyProb-Dist-Toll-Forecast-Uncertainty
Prob-Dist-Toll-Forecast-UncertaintyAnkoor Bhagat
 
Stupid Awesome Python Tricks
Stupid Awesome Python TricksStupid Awesome Python Tricks
Stupid Awesome Python Tricks
Bryan Helmig
 
Welcome to python
Welcome to pythonWelcome to python
Welcome to python
Kyunghoon Kim
 
Computer graphics lab manual
Computer graphics lab manualComputer graphics lab manual
Computer graphics lab manual
Uma mohan
 
Gems of GameplayKit. UA Mobile 2017.
Gems of GameplayKit. UA Mobile 2017.Gems of GameplayKit. UA Mobile 2017.
Gems of GameplayKit. UA Mobile 2017.
UA Mobile
 
Convolutional Neural Network
Convolutional Neural NetworkConvolutional Neural Network
Convolutional Neural Network
Jun Young Park
 
Thinking Functionally In Ruby
Thinking Functionally In RubyThinking Functionally In Ruby
Thinking Functionally In RubyRoss Lawley
 
โปรแกรมย่อยและฟังชันก์มาตรฐาน
โปรแกรมย่อยและฟังชันก์มาตรฐานโปรแกรมย่อยและฟังชันก์มาตรฐาน
โปรแกรมย่อยและฟังชันก์มาตรฐานknang
 
Coding in Style
Coding in StyleCoding in Style
Coding in Style
scalaconfjp
 

Similar to Cursor implementation (20)

20110424 action scriptを使わないflash勉強会
20110424 action scriptを使わないflash勉強会20110424 action scriptを使わないflash勉強会
20110424 action scriptを使わないflash勉強会
 
Sparse Matrix and Polynomial
Sparse Matrix and PolynomialSparse Matrix and Polynomial
Sparse Matrix and Polynomial
 
Haskellで学ぶ関数型言語
Haskellで学ぶ関数型言語Haskellで学ぶ関数型言語
Haskellで学ぶ関数型言語
 
The Groovy Puzzlers – The Complete 01 and 02 Seasons
The Groovy Puzzlers – The Complete 01 and 02 SeasonsThe Groovy Puzzlers – The Complete 01 and 02 Seasons
The Groovy Puzzlers – The Complete 01 and 02 Seasons
 
Clase de matlab
Clase de matlabClase de matlab
Clase de matlab
 
Clase de matlab
Clase de matlabClase de matlab
Clase de matlab
 
INTRODUCTION TO MATLAB presentation.pptx
INTRODUCTION TO MATLAB presentation.pptxINTRODUCTION TO MATLAB presentation.pptx
INTRODUCTION TO MATLAB presentation.pptx
 
Functional Programming In Mathematica
Functional Programming In MathematicaFunctional Programming In Mathematica
Functional Programming In Mathematica
 
Vcs16
Vcs16Vcs16
Vcs16
 
Prob-Dist-Toll-Forecast-Uncertainty
Prob-Dist-Toll-Forecast-UncertaintyProb-Dist-Toll-Forecast-Uncertainty
Prob-Dist-Toll-Forecast-Uncertainty
 
Stupid Awesome Python Tricks
Stupid Awesome Python TricksStupid Awesome Python Tricks
Stupid Awesome Python Tricks
 
Welcome to python
Welcome to pythonWelcome to python
Welcome to python
 
Computer graphics lab manual
Computer graphics lab manualComputer graphics lab manual
Computer graphics lab manual
 
Mit6 094 iap10_lec03
Mit6 094 iap10_lec03Mit6 094 iap10_lec03
Mit6 094 iap10_lec03
 
V8
V8V8
V8
 
Gems of GameplayKit. UA Mobile 2017.
Gems of GameplayKit. UA Mobile 2017.Gems of GameplayKit. UA Mobile 2017.
Gems of GameplayKit. UA Mobile 2017.
 
Convolutional Neural Network
Convolutional Neural NetworkConvolutional Neural Network
Convolutional Neural Network
 
Thinking Functionally In Ruby
Thinking Functionally In RubyThinking Functionally In Ruby
Thinking Functionally In Ruby
 
โปรแกรมย่อยและฟังชันก์มาตรฐาน
โปรแกรมย่อยและฟังชันก์มาตรฐานโปรแกรมย่อยและฟังชันก์มาตรฐาน
โปรแกรมย่อยและฟังชันก์มาตรฐาน
 
Coding in Style
Coding in StyleCoding in Style
Coding in Style
 

Recently uploaded

原版制作(RMIT毕业证书)墨尔本皇家理工大学毕业证在读证明一模一样
原版制作(RMIT毕业证书)墨尔本皇家理工大学毕业证在读证明一模一样原版制作(RMIT毕业证书)墨尔本皇家理工大学毕业证在读证明一模一样
原版制作(RMIT毕业证书)墨尔本皇家理工大学毕业证在读证明一模一样
atwvhyhm
 
一比一原版(TMU毕业证)多伦多都会大学毕业证如何办理
一比一原版(TMU毕业证)多伦多都会大学毕业证如何办理一比一原版(TMU毕业证)多伦多都会大学毕业证如何办理
一比一原版(TMU毕业证)多伦多都会大学毕业证如何办理
yuhofha
 
The Impact of Artificial Intelligence on Modern Society.pdf
The Impact of Artificial Intelligence on Modern Society.pdfThe Impact of Artificial Intelligence on Modern Society.pdf
The Impact of Artificial Intelligence on Modern Society.pdf
ssuser3e63fc
 
How to Master LinkedIn for Career and Business
How to Master LinkedIn for Career and BusinessHow to Master LinkedIn for Career and Business
How to Master LinkedIn for Career and Business
ideatoipo
 
Heidi Livengood Resume Senior Technical Recruiter / HR Generalist
Heidi Livengood Resume Senior Technical Recruiter / HR GeneralistHeidi Livengood Resume Senior Technical Recruiter / HR Generalist
Heidi Livengood Resume Senior Technical Recruiter / HR Generalist
HeidiLivengood
 
欧洲杯买球平台-欧洲杯买球平台推荐-欧洲杯买球平台| 立即访问【ac123.net】
欧洲杯买球平台-欧洲杯买球平台推荐-欧洲杯买球平台| 立即访问【ac123.net】欧洲杯买球平台-欧洲杯买球平台推荐-欧洲杯买球平台| 立即访问【ac123.net】
欧洲杯买球平台-欧洲杯买球平台推荐-欧洲杯买球平台| 立即访问【ac123.net】
foismail170
 
Chapters 3 Contracts.pptx Chapters 3 Contracts.pptx
Chapters 3  Contracts.pptx Chapters 3  Contracts.pptxChapters 3  Contracts.pptx Chapters 3  Contracts.pptx
Chapters 3 Contracts.pptx Chapters 3 Contracts.pptx
Sheldon Byron
 
Full Sail_Morales_Michael_SMM_2024-05.pptx
Full Sail_Morales_Michael_SMM_2024-05.pptxFull Sail_Morales_Michael_SMM_2024-05.pptx
Full Sail_Morales_Michael_SMM_2024-05.pptx
mmorales2173
 
Transferable Skills - Your Roadmap - Part 1 and 2 - Dirk Spencer Senior Recru...
Transferable Skills - Your Roadmap - Part 1 and 2 - Dirk Spencer Senior Recru...Transferable Skills - Your Roadmap - Part 1 and 2 - Dirk Spencer Senior Recru...
Transferable Skills - Your Roadmap - Part 1 and 2 - Dirk Spencer Senior Recru...
Dirk Spencer Corporate Recruiter LION
 
DIGITAL MARKETING COURSE IN CHENNAI.pptx
DIGITAL MARKETING COURSE IN CHENNAI.pptxDIGITAL MARKETING COURSE IN CHENNAI.pptx
DIGITAL MARKETING COURSE IN CHENNAI.pptx
FarzanaRbcomcs
 
Andrea Kate Portfolio Presentation.pdf
Andrea Kate  Portfolio  Presentation.pdfAndrea Kate  Portfolio  Presentation.pdf
Andrea Kate Portfolio Presentation.pdf
andreakaterasco
 
Interactive Dictionary AIDS-B.pptx aaaaaaaaaaaaaaaaaaaaaaaaaa
Interactive Dictionary AIDS-B.pptx aaaaaaaaaaaaaaaaaaaaaaaaaaInteractive Dictionary AIDS-B.pptx aaaaaaaaaaaaaaaaaaaaaaaaaa
Interactive Dictionary AIDS-B.pptx aaaaaaaaaaaaaaaaaaaaaaaaaa
23211a7274
 
134. Reviewer Certificate in Computer Science
134. Reviewer Certificate in Computer Science134. Reviewer Certificate in Computer Science
134. Reviewer Certificate in Computer Science
Manu Mitra
 
135. Reviewer Certificate in Journal of Engineering
135. Reviewer Certificate in Journal of Engineering135. Reviewer Certificate in Journal of Engineering
135. Reviewer Certificate in Journal of Engineering
Manu Mitra
 
一比一原版(YU毕业证)约克大学毕业证如何办理
一比一原版(YU毕业证)约克大学毕业证如何办理一比一原版(YU毕业证)约克大学毕业证如何办理
一比一原版(YU毕业证)约克大学毕业证如何办理
yuhofha
 
How Mentoring Elevates Your PM Career | PMI Silver Spring Chapter
How Mentoring Elevates Your PM Career | PMI Silver Spring ChapterHow Mentoring Elevates Your PM Career | PMI Silver Spring Chapter
How Mentoring Elevates Your PM Career | PMI Silver Spring Chapter
Hector Del Castillo, CPM, CPMM
 
RECOGNITION AWARD 13 - TO ALESSANDRO MARTINS.pdf
RECOGNITION AWARD 13 - TO ALESSANDRO MARTINS.pdfRECOGNITION AWARD 13 - TO ALESSANDRO MARTINS.pdf
RECOGNITION AWARD 13 - TO ALESSANDRO MARTINS.pdf
AlessandroMartins454470
 
DOC-20240602-WA0001..pdf DOC-20240602-WA0001..pdf
DOC-20240602-WA0001..pdf DOC-20240602-WA0001..pdfDOC-20240602-WA0001..pdf DOC-20240602-WA0001..pdf
DOC-20240602-WA0001..pdf DOC-20240602-WA0001..pdf
Pushpendra Kumar
 
How to create an effective K-POC tutorial
How to create an effective K-POC tutorialHow to create an effective K-POC tutorial
How to create an effective K-POC tutorial
vencislavkaaa
 
Digital Marketing Training In Bangalore
Digital  Marketing Training In BangaloreDigital  Marketing Training In Bangalore
Digital Marketing Training In Bangalore
nidm599
 

Recently uploaded (20)

原版制作(RMIT毕业证书)墨尔本皇家理工大学毕业证在读证明一模一样
原版制作(RMIT毕业证书)墨尔本皇家理工大学毕业证在读证明一模一样原版制作(RMIT毕业证书)墨尔本皇家理工大学毕业证在读证明一模一样
原版制作(RMIT毕业证书)墨尔本皇家理工大学毕业证在读证明一模一样
 
一比一原版(TMU毕业证)多伦多都会大学毕业证如何办理
一比一原版(TMU毕业证)多伦多都会大学毕业证如何办理一比一原版(TMU毕业证)多伦多都会大学毕业证如何办理
一比一原版(TMU毕业证)多伦多都会大学毕业证如何办理
 
The Impact of Artificial Intelligence on Modern Society.pdf
The Impact of Artificial Intelligence on Modern Society.pdfThe Impact of Artificial Intelligence on Modern Society.pdf
The Impact of Artificial Intelligence on Modern Society.pdf
 
How to Master LinkedIn for Career and Business
How to Master LinkedIn for Career and BusinessHow to Master LinkedIn for Career and Business
How to Master LinkedIn for Career and Business
 
Heidi Livengood Resume Senior Technical Recruiter / HR Generalist
Heidi Livengood Resume Senior Technical Recruiter / HR GeneralistHeidi Livengood Resume Senior Technical Recruiter / HR Generalist
Heidi Livengood Resume Senior Technical Recruiter / HR Generalist
 
欧洲杯买球平台-欧洲杯买球平台推荐-欧洲杯买球平台| 立即访问【ac123.net】
欧洲杯买球平台-欧洲杯买球平台推荐-欧洲杯买球平台| 立即访问【ac123.net】欧洲杯买球平台-欧洲杯买球平台推荐-欧洲杯买球平台| 立即访问【ac123.net】
欧洲杯买球平台-欧洲杯买球平台推荐-欧洲杯买球平台| 立即访问【ac123.net】
 
Chapters 3 Contracts.pptx Chapters 3 Contracts.pptx
Chapters 3  Contracts.pptx Chapters 3  Contracts.pptxChapters 3  Contracts.pptx Chapters 3  Contracts.pptx
Chapters 3 Contracts.pptx Chapters 3 Contracts.pptx
 
Full Sail_Morales_Michael_SMM_2024-05.pptx
Full Sail_Morales_Michael_SMM_2024-05.pptxFull Sail_Morales_Michael_SMM_2024-05.pptx
Full Sail_Morales_Michael_SMM_2024-05.pptx
 
Transferable Skills - Your Roadmap - Part 1 and 2 - Dirk Spencer Senior Recru...
Transferable Skills - Your Roadmap - Part 1 and 2 - Dirk Spencer Senior Recru...Transferable Skills - Your Roadmap - Part 1 and 2 - Dirk Spencer Senior Recru...
Transferable Skills - Your Roadmap - Part 1 and 2 - Dirk Spencer Senior Recru...
 
DIGITAL MARKETING COURSE IN CHENNAI.pptx
DIGITAL MARKETING COURSE IN CHENNAI.pptxDIGITAL MARKETING COURSE IN CHENNAI.pptx
DIGITAL MARKETING COURSE IN CHENNAI.pptx
 
Andrea Kate Portfolio Presentation.pdf
Andrea Kate  Portfolio  Presentation.pdfAndrea Kate  Portfolio  Presentation.pdf
Andrea Kate Portfolio Presentation.pdf
 
Interactive Dictionary AIDS-B.pptx aaaaaaaaaaaaaaaaaaaaaaaaaa
Interactive Dictionary AIDS-B.pptx aaaaaaaaaaaaaaaaaaaaaaaaaaInteractive Dictionary AIDS-B.pptx aaaaaaaaaaaaaaaaaaaaaaaaaa
Interactive Dictionary AIDS-B.pptx aaaaaaaaaaaaaaaaaaaaaaaaaa
 
134. Reviewer Certificate in Computer Science
134. Reviewer Certificate in Computer Science134. Reviewer Certificate in Computer Science
134. Reviewer Certificate in Computer Science
 
135. Reviewer Certificate in Journal of Engineering
135. Reviewer Certificate in Journal of Engineering135. Reviewer Certificate in Journal of Engineering
135. Reviewer Certificate in Journal of Engineering
 
一比一原版(YU毕业证)约克大学毕业证如何办理
一比一原版(YU毕业证)约克大学毕业证如何办理一比一原版(YU毕业证)约克大学毕业证如何办理
一比一原版(YU毕业证)约克大学毕业证如何办理
 
How Mentoring Elevates Your PM Career | PMI Silver Spring Chapter
How Mentoring Elevates Your PM Career | PMI Silver Spring ChapterHow Mentoring Elevates Your PM Career | PMI Silver Spring Chapter
How Mentoring Elevates Your PM Career | PMI Silver Spring Chapter
 
RECOGNITION AWARD 13 - TO ALESSANDRO MARTINS.pdf
RECOGNITION AWARD 13 - TO ALESSANDRO MARTINS.pdfRECOGNITION AWARD 13 - TO ALESSANDRO MARTINS.pdf
RECOGNITION AWARD 13 - TO ALESSANDRO MARTINS.pdf
 
DOC-20240602-WA0001..pdf DOC-20240602-WA0001..pdf
DOC-20240602-WA0001..pdf DOC-20240602-WA0001..pdfDOC-20240602-WA0001..pdf DOC-20240602-WA0001..pdf
DOC-20240602-WA0001..pdf DOC-20240602-WA0001..pdf
 
How to create an effective K-POC tutorial
How to create an effective K-POC tutorialHow to create an effective K-POC tutorial
How to create an effective K-POC tutorial
 
Digital Marketing Training In Bangalore
Digital  Marketing Training In BangaloreDigital  Marketing Training In Bangalore
Digital Marketing Training In Bangalore
 

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