SlideShare une entreprise Scribd logo
1  sur  50
Télécharger pour lire hors ligne
Team Emertxe
Strings and Storage
Classes
Assignment 9
Assignment 9
Assignment 9
WAP to generate consecutive NRPS of length ‘n’ using ‘k’
distinct character
Assignment 9
WAP to generate consecutive NRPS of length ‘n’ using ‘k’
distinct character
Input:
Assignment 9
WAP to generate consecutive NRPS of length ‘n’ using ‘k’
distinct character
Input: Read Positive integers - number of characters ‘k’,
length of the string ‘n’ and ‘k’ distinct characters.
Assignment 9
WAP to generate consecutive NRPS of length ‘n’ using ‘k’
distinct character
Input: Read Positive integers - number of characters ‘k’,
length of the string ‘n’ and ‘k’ distinct characters.
Output:
Assignment 9
WAP to generate consecutive NRPS of length ‘n’ using ‘k’
distinct character
Input: Read Positive integers - number of characters ‘k’,
length of the string ‘n’ and ‘k’ distinct characters.
Output: Print NRPS.
Assignment 9
What is NRPS?
Assignment 9
What is NRPS?
 NRPS means Non-Repetitive Pattern String.
Assignment 9
What is NRPS?
 NRPS means Non-Repetitive Pattern String.
 Example: abcdabdc -> This string is formed using 4 distinct
characters ‘a’, ‘b’, ‘c’ and ‘d’ of string length 8.
 The pattern should not be repeated consecutively.
Assignment 9
How will you check the string is NRPS or not?
Assignment 9
How will you check the string is NRPS or not?
 Example: abcdabdc -> This string is formed using 4 distinct
characters ‘a’, ‘b’, ‘c’ and ‘d’ of string length 8.
Assignment 9
How will you check the string is NRPS or not?
 Example: abcdabdc -> This string is formed using 4 distinct
characters ‘a’, ‘b’, ‘c’ and ‘d’ of string length 8.
a b c d a b d c 0
NRPS
Assignment 9
How will you check the string is NRPS or not?
 Example: abcdabdc -> This string is formed using 4 distinct
characters ‘a’, ‘b’, ‘c’ and ‘d’ of string length 8.
a b c d a b d c 0
NRPS
First pattern is formed
using the characters a,
b, c and d in order.
Assignment 9
How will you check the string is NRPS or not?
 Example: abcdabdc -> This string is formed using 4 distinct
characters ‘a’, ‘b’, ‘c’ and ‘d’ of string length 8.
a b c d a b d c 0
NRPS
Next pattern is formed
by swapping some
characters. The
pattern should not be
same as previous
pattern.
Assignment 9
How will you check the string is NRPS or not?
 Step 1: Make use of count variable. Initial value of count is 0.
count = 0.
a b c d a b d c 0
NRPS
Assignment 9
How will you check the string is NRPS or not?
 Step 2: Start comparing the elements of first pattern and
second pattern using their indices.
a b c d a b d c 0
NRPS
Assignment 9
How will you check the string is NRPS or not?
 Step 2: Start from ‘a’ from abcd and ‘a’ from abdc.
 If, both are same, increment count by 1
a b c d a b d c 0
NRPS
count = 1
Assignment 9
How will you check the string is NRPS or not?
 Step 2: Then ‘b’ from abcd and ‘b’ from abdc.
 If, both are same, increment count by 1
a b c d a b d c 0
NRPS
count = 2
Assignment 9
How will you check the string is NRPS or not?
 Step 2: Then ‘c’ from abcd and ‘d’ from abdc.
 If, both are same, increment count by 1
 If not, reset the count value to 0.
a b c d a b d c 0
NRPS
count = 0
Assignment 9
How will you check the string is NRPS or not?
 Step 2: Then ‘d’ from abcd and ‘c’ from abdc.
 If, both are same, increment count by 1
 If not, reset the count value to 0.
a b c d a b d c 0
NRPS
count = 0
Assignment 9
How will you check the string is NRPS or not?
 Step 3: Check the count value.
• If the count value is 0, then the string is NRPS.
• If the count value is other then 0, then the string is not NRPS.
a b c d a b d c 0
NRPS
count = 0
Assignment 9
How will you check the string is NRPS or not?
 Step 3: Check the count value.
• If the count value is 0, then the string is NRPS.
• If the count value is other then 0, then the string is not NRPS.
• Here, the count value is 0, so, abcdabdc is NRPS.
a b c d a b d c 0
NRPS
count = 0
Assignment 9
How to create a NRPS?
Assignment 9
How to create a NRPS?
 Read how many distinct characters(k) are required to create
NRPS from user. Assume ‘k’ = 3.
 Read 3 distinct characters from user i.e., ‘a’, ‘b’ and ‘c’.
 Read the length(n) of the string to be formed using ‘k’ distinct
characters. n = 6.
Assignment 9
How to create a NRPS?
 k = 3, n = 6 and characters are ‘a’, ‘b’ and ‘c’.
 Step 1: Create the first pattern of characters in order.
a b c
NRPS
Assignment 9
How to create a NRPS?
 k = 3, n = 6 and characters are ‘a’, ‘b’ and ‘c’.
 Step2: Start creating the next pattern starting from index 1.
a b c b
NRPS
Assignment 9
How to create a NRPS?
 k = 3, n = 6 and characters are ‘a’, ‘b’ and ‘c’.
 Step2: Next index 2 can be copied to index 4.
a b c b c
NRPS
Assignment 9
How to create a NRPS?
 k = 3, n = 6 and characters are ‘a’, ‘b’ and ‘c’.
 Step2: When you reach end of the first pattern, start from the
beginning again.
a b c b c a
NRPS
Assignment 9
How to create a NRPS?
 k = 3, n = 6 and characters are ‘a’, ‘b’ and ‘c’.
a b c b c a 0
NRPS
Assignment 9
How to create a NRPS?
 Read how many distinct characters(k) are required to create
NRPS from user. Assume ‘k’ = 3.
 Read 3 distinct characters from user i.e., ‘a’, ‘b’ and ‘c’.
 Read the length(n) of the string to be formed using ‘k’ distinct
characters. n = 9.
Assignment 9
How to create a NRPS?
 k = 3, n = 9 and characters are ‘a’, ‘b’ and ‘c’.
 Step 1: Create the first pattern of characters in order.
a b c
NRPS
Assignment 9
How to create a NRPS?
 k = 3, n = 9 and characters are ‘a’, ‘b’ and ‘c’.
 Step2: Start creating the next pattern starting from index 1.
NRPS a b c b
Assignment 9
How to create a NRPS?
 k = 3, n = 9 and characters are ‘a’, ‘b’ and ‘c’.
 Step2: Next index 2 can be copied to index 4.
NRPS a b c b c
Assignment 9
How to create a NRPS?
 k = 3, n = 9 and characters are ‘a’, ‘b’ and ‘c’.
 Step2: When you reach end of the first pattern, start from the
beginning again.
NRPS a b c b c a
Assignment 9
How to create a NRPS?
 k = 3, n = 9 and characters are ‘a’, ‘b’ and ‘c’.
 Step1: Repeat the process to create next pattern till length ‘n’.
NRPS a b c b c a c
Assignment 9
How to create a NRPS?
 k = 3, n = 9 and characters are ‘a’, ‘b’ and ‘c’.
 Step1: Repeat the process to create next pattern till length ‘n’.
NRPS a b c b c a c a
Assignment 9
How to create a NRPS?
 k = 3, n = 9 and characters are ‘a’, ‘b’ and ‘c’.
 Step1: Repeat the process to create next pattern till length ‘n’.
NRPS a b c b c a c a b
Assignment 9
How to create a NRPS?
 k = 3, n = 8 and characters are ‘a’, ‘b’ and ‘c’.
NRPS a b c b c a c a b 0
Assignment 9
Sample execution:-
Assignment 9
Sample execution:-
Assignment 9
Sample execution:-
Assignment 9
Pre-requisites:-
Assignment 9
Pre-requisites:-
⮚Strings
Assignment 9
Pre-requisites:-
⮚Strings
⮚Arrays
Assignment 9
Pre-requisites:-
⮚Strings
⮚Arrays
⮚Pointers
Assignment 9
Pre-requisites:-
⮚Strings
⮚Arrays
⮚Pointers
Objective:-
Assignment 9
Pre-requisites:-
⮚Strings
⮚Arrays
⮚Pointers
Objective:-
To understand the concept of String manipulation
Team Emertxe
Thank you

Contenu connexe

Tendances

SystemVerilog Assertion.pptx
SystemVerilog Assertion.pptxSystemVerilog Assertion.pptx
SystemVerilog Assertion.pptxNothing!
 
Introduction to System verilog
Introduction to System verilog Introduction to System verilog
Introduction to System verilog Pushpa Yakkala
 
02 ldpc bit flipping_decoding_dark knight
02 ldpc bit flipping_decoding_dark knight02 ldpc bit flipping_decoding_dark knight
02 ldpc bit flipping_decoding_dark knightDevanshi Piprottar
 
Verilog Test Bench
Verilog Test BenchVerilog Test Bench
Verilog Test BenchDr.YNM
 
Design of Power and Area Efficient Approximate Multipliers
Design of Power and Area Efficient Approximate MultipliersDesign of Power and Area Efficient Approximate Multipliers
Design of Power and Area Efficient Approximate MultipliersJAYAPRAKASH JPINFOTECH
 
Convolutional Neural Networks (CNN) — 卷積神經網路的前世今生
Convolutional Neural Networks (CNN) — 卷積神經網路的前世今生Convolutional Neural Networks (CNN) — 卷積神經網路的前世今生
Convolutional Neural Networks (CNN) — 卷積神經網路的前世今生Jason Tsai
 
Security issues in FPGA based systems.
Security issues in FPGA based systems.Security issues in FPGA based systems.
Security issues in FPGA based systems.Rajeev Verma
 
Embedded Systems (18EC62) – Embedded System Design Concepts (Module 4)
Embedded Systems (18EC62) – Embedded System Design Concepts (Module 4)Embedded Systems (18EC62) – Embedded System Design Concepts (Module 4)
Embedded Systems (18EC62) – Embedded System Design Concepts (Module 4)Shrishail Bhat
 
Minimization of switching functions
Minimization of switching functionsMinimization of switching functions
Minimization of switching functionssaanavi
 
Semi Custom Integrated Circuit Design
 Semi Custom Integrated Circuit Design Semi Custom Integrated Circuit Design
Semi Custom Integrated Circuit DesignDr.YNM
 

Tendances (20)

Fltk tutorial
Fltk tutorialFltk tutorial
Fltk tutorial
 
Half adder layout design
Half adder layout designHalf adder layout design
Half adder layout design
 
SystemVerilog Assertion.pptx
SystemVerilog Assertion.pptxSystemVerilog Assertion.pptx
SystemVerilog Assertion.pptx
 
FPGA
FPGAFPGA
FPGA
 
verilog
verilogverilog
verilog
 
Introduction to EDA Tools
Introduction to EDA ToolsIntroduction to EDA Tools
Introduction to EDA Tools
 
Logic Programming and ILP
Logic Programming and ILPLogic Programming and ILP
Logic Programming and ILP
 
Introduction to System verilog
Introduction to System verilog Introduction to System verilog
Introduction to System verilog
 
02 ldpc bit flipping_decoding_dark knight
02 ldpc bit flipping_decoding_dark knight02 ldpc bit flipping_decoding_dark knight
02 ldpc bit flipping_decoding_dark knight
 
Verilog Test Bench
Verilog Test BenchVerilog Test Bench
Verilog Test Bench
 
Design of Power and Area Efficient Approximate Multipliers
Design of Power and Area Efficient Approximate MultipliersDesign of Power and Area Efficient Approximate Multipliers
Design of Power and Area Efficient Approximate Multipliers
 
Convolutional Neural Networks (CNN) — 卷積神經網路的前世今生
Convolutional Neural Networks (CNN) — 卷積神經網路的前世今生Convolutional Neural Networks (CNN) — 卷積神經網路的前世今生
Convolutional Neural Networks (CNN) — 卷積神經網路的前世今生
 
Security issues in FPGA based systems.
Security issues in FPGA based systems.Security issues in FPGA based systems.
Security issues in FPGA based systems.
 
Lisp
LispLisp
Lisp
 
Vliw
VliwVliw
Vliw
 
Embedded Systems (18EC62) – Embedded System Design Concepts (Module 4)
Embedded Systems (18EC62) – Embedded System Design Concepts (Module 4)Embedded Systems (18EC62) – Embedded System Design Concepts (Module 4)
Embedded Systems (18EC62) – Embedded System Design Concepts (Module 4)
 
Crash course in verilog
Crash course in verilogCrash course in verilog
Crash course in verilog
 
VHDL
VHDLVHDL
VHDL
 
Minimization of switching functions
Minimization of switching functionsMinimization of switching functions
Minimization of switching functions
 
Semi Custom Integrated Circuit Design
 Semi Custom Integrated Circuit Design Semi Custom Integrated Circuit Design
Semi Custom Integrated Circuit Design
 

Similaire à Generate NRPS Strings of Length n using k Characters

String in c in erode SENGUNTHAR engineering .pptx
String in c in erode SENGUNTHAR engineering .pptxString in c in erode SENGUNTHAR engineering .pptx
String in c in erode SENGUNTHAR engineering .pptxmani123123r
 
Teoria y problemas de numeros racionales qa312 ccesa007
Teoria y problemas de numeros racionales qa312 ccesa007Teoria y problemas de numeros racionales qa312 ccesa007
Teoria y problemas de numeros racionales qa312 ccesa007Demetrio Ccesa Rayme
 
REAL AND COMPLEX NUMBERS​ And INDICES, SURD & LOGARITHM​
REAL AND COMPLEX NUMBERS​ And INDICES, SURD & LOGARITHM​REAL AND COMPLEX NUMBERS​ And INDICES, SURD & LOGARITHM​
REAL AND COMPLEX NUMBERS​ And INDICES, SURD & LOGARITHM​Reema
 
Permutations and Combinations IIT JEE+Olympiad Lecture 4
Permutations and Combinations IIT JEE+Olympiad Lecture 4Permutations and Combinations IIT JEE+Olympiad Lecture 4
Permutations and Combinations IIT JEE+Olympiad Lecture 4Parth Nandedkar
 
String matching algorithms(knuth morris-pratt)
String matching algorithms(knuth morris-pratt)String matching algorithms(knuth morris-pratt)
String matching algorithms(knuth morris-pratt)Neel Shah
 
MultipleObjectDepthMapRec
MultipleObjectDepthMapRecMultipleObjectDepthMapRec
MultipleObjectDepthMapRecZachary Job
 
laiba presentation.pptx
laiba presentation.pptxlaiba presentation.pptx
laiba presentation.pptxAaminaJavid
 

Similaire à Generate NRPS Strings of Length n using k Characters (14)

String in c in erode SENGUNTHAR engineering .pptx
String in c in erode SENGUNTHAR engineering .pptxString in c in erode SENGUNTHAR engineering .pptx
String in c in erode SENGUNTHAR engineering .pptx
 
String matching algorithm
String matching algorithmString matching algorithm
String matching algorithm
 
06_replace_n_bits_pos.pdf
06_replace_n_bits_pos.pdf06_replace_n_bits_pos.pdf
06_replace_n_bits_pos.pdf
 
09_isalnum.pdf
09_isalnum.pdf09_isalnum.pdf
09_isalnum.pdf
 
Teoria y problemas de numeros racionales qa312 ccesa007
Teoria y problemas de numeros racionales qa312 ccesa007Teoria y problemas de numeros racionales qa312 ccesa007
Teoria y problemas de numeros racionales qa312 ccesa007
 
JMM2016PosterFinal
JMM2016PosterFinalJMM2016PosterFinal
JMM2016PosterFinal
 
Ch-3 lecture.pdf
Ch-3 lecture.pdfCh-3 lecture.pdf
Ch-3 lecture.pdf
 
REAL AND COMPLEX NUMBERS​ And INDICES, SURD & LOGARITHM​
REAL AND COMPLEX NUMBERS​ And INDICES, SURD & LOGARITHM​REAL AND COMPLEX NUMBERS​ And INDICES, SURD & LOGARITHM​
REAL AND COMPLEX NUMBERS​ And INDICES, SURD & LOGARITHM​
 
Permutations and Combinations IIT JEE+Olympiad Lecture 4
Permutations and Combinations IIT JEE+Olympiad Lecture 4Permutations and Combinations IIT JEE+Olympiad Lecture 4
Permutations and Combinations IIT JEE+Olympiad Lecture 4
 
Computer Science Exam Help
Computer Science Exam Help Computer Science Exam Help
Computer Science Exam Help
 
String matching algorithms(knuth morris-pratt)
String matching algorithms(knuth morris-pratt)String matching algorithms(knuth morris-pratt)
String matching algorithms(knuth morris-pratt)
 
MultipleObjectDepthMapRec
MultipleObjectDepthMapRecMultipleObjectDepthMapRec
MultipleObjectDepthMapRec
 
K Means Clustering in ML.pptx
K Means Clustering in ML.pptxK Means Clustering in ML.pptx
K Means Clustering in ML.pptx
 
laiba presentation.pptx
laiba presentation.pptxlaiba presentation.pptx
laiba presentation.pptx
 

Plus de Emertxe Information Technologies Pvt Ltd

Plus de Emertxe Information Technologies Pvt Ltd (20)

premium post (1).pdf
premium post (1).pdfpremium post (1).pdf
premium post (1).pdf
 
Career Transition (1).pdf
Career Transition (1).pdfCareer Transition (1).pdf
Career Transition (1).pdf
 
10_isxdigit.pdf
10_isxdigit.pdf10_isxdigit.pdf
10_isxdigit.pdf
 
01_student_record.pdf
01_student_record.pdf01_student_record.pdf
01_student_record.pdf
 
02_swap.pdf
02_swap.pdf02_swap.pdf
02_swap.pdf
 
01_sizeof.pdf
01_sizeof.pdf01_sizeof.pdf
01_sizeof.pdf
 
07_product_matrix.pdf
07_product_matrix.pdf07_product_matrix.pdf
07_product_matrix.pdf
 
06_sort_names.pdf
06_sort_names.pdf06_sort_names.pdf
06_sort_names.pdf
 
05_fragments.pdf
05_fragments.pdf05_fragments.pdf
05_fragments.pdf
 
04_magic_square.pdf
04_magic_square.pdf04_magic_square.pdf
04_magic_square.pdf
 
03_endianess.pdf
03_endianess.pdf03_endianess.pdf
03_endianess.pdf
 
02_variance.pdf
02_variance.pdf02_variance.pdf
02_variance.pdf
 
01_memory_manager.pdf
01_memory_manager.pdf01_memory_manager.pdf
01_memory_manager.pdf
 
11_pangram.pdf
11_pangram.pdf11_pangram.pdf
11_pangram.pdf
 
10_combinations.pdf
10_combinations.pdf10_combinations.pdf
10_combinations.pdf
 
08_squeeze.pdf
08_squeeze.pdf08_squeeze.pdf
08_squeeze.pdf
 
07_strtok.pdf
07_strtok.pdf07_strtok.pdf
07_strtok.pdf
 
06_reverserec.pdf
06_reverserec.pdf06_reverserec.pdf
06_reverserec.pdf
 
05_reverseiter.pdf
05_reverseiter.pdf05_reverseiter.pdf
05_reverseiter.pdf
 
04_itoa.pdf
04_itoa.pdf04_itoa.pdf
04_itoa.pdf
 

Dernier

AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdfAMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdfphamnguyenenglishnb
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxiammrhaywood
 
ACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdfACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdfSpandanaRallapalli
 
Karra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptxKarra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptxAshokKarra1
 
Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Celine George
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatYousafMalik24
 
Concurrency Control in Database Management system
Concurrency Control in Database Management systemConcurrency Control in Database Management system
Concurrency Control in Database Management systemChristalin Nelson
 
ENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomnelietumpap1
 
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfLike-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfMr Bounab Samir
 
Global Lehigh Strategic Initiatives (without descriptions)
Global Lehigh Strategic Initiatives (without descriptions)Global Lehigh Strategic Initiatives (without descriptions)
Global Lehigh Strategic Initiatives (without descriptions)cama23
 
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITYISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITYKayeClaireEstoconing
 
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxINTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxHumphrey A Beña
 
FILIPINO PSYCHology sikolohiyang pilipino
FILIPINO PSYCHology sikolohiyang pilipinoFILIPINO PSYCHology sikolohiyang pilipino
FILIPINO PSYCHology sikolohiyang pilipinojohnmickonozaleda
 
Judging the Relevance and worth of ideas part 2.pptx
Judging the Relevance  and worth of ideas part 2.pptxJudging the Relevance  and worth of ideas part 2.pptx
Judging the Relevance and worth of ideas part 2.pptxSherlyMaeNeri
 
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxMULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxAnupkumar Sharma
 
AUDIENCE THEORY -CULTIVATION THEORY - GERBNER.pptx
AUDIENCE THEORY -CULTIVATION THEORY -  GERBNER.pptxAUDIENCE THEORY -CULTIVATION THEORY -  GERBNER.pptx
AUDIENCE THEORY -CULTIVATION THEORY - GERBNER.pptxiammrhaywood
 
Science 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptxScience 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptxMaryGraceBautista27
 

Dernier (20)

AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdfAMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
 
ACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdfACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdf
 
Karra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptxKarra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptx
 
Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice great
 
Concurrency Control in Database Management system
Concurrency Control in Database Management systemConcurrency Control in Database Management system
Concurrency Control in Database Management system
 
FINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptx
FINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptxFINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptx
FINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptx
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
ENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choom
 
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfLike-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
 
Global Lehigh Strategic Initiatives (without descriptions)
Global Lehigh Strategic Initiatives (without descriptions)Global Lehigh Strategic Initiatives (without descriptions)
Global Lehigh Strategic Initiatives (without descriptions)
 
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITYISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
 
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxINTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
 
FILIPINO PSYCHology sikolohiyang pilipino
FILIPINO PSYCHology sikolohiyang pilipinoFILIPINO PSYCHology sikolohiyang pilipino
FILIPINO PSYCHology sikolohiyang pilipino
 
Judging the Relevance and worth of ideas part 2.pptx
Judging the Relevance  and worth of ideas part 2.pptxJudging the Relevance  and worth of ideas part 2.pptx
Judging the Relevance and worth of ideas part 2.pptx
 
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxMULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
 
AUDIENCE THEORY -CULTIVATION THEORY - GERBNER.pptx
AUDIENCE THEORY -CULTIVATION THEORY -  GERBNER.pptxAUDIENCE THEORY -CULTIVATION THEORY -  GERBNER.pptx
AUDIENCE THEORY -CULTIVATION THEORY - GERBNER.pptx
 
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptxLEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
 
Science 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptxScience 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptx
 

Generate NRPS Strings of Length n using k Characters

  • 1. Team Emertxe Strings and Storage Classes
  • 4. Assignment 9 WAP to generate consecutive NRPS of length ‘n’ using ‘k’ distinct character
  • 5. Assignment 9 WAP to generate consecutive NRPS of length ‘n’ using ‘k’ distinct character Input:
  • 6. Assignment 9 WAP to generate consecutive NRPS of length ‘n’ using ‘k’ distinct character Input: Read Positive integers - number of characters ‘k’, length of the string ‘n’ and ‘k’ distinct characters.
  • 7. Assignment 9 WAP to generate consecutive NRPS of length ‘n’ using ‘k’ distinct character Input: Read Positive integers - number of characters ‘k’, length of the string ‘n’ and ‘k’ distinct characters. Output:
  • 8. Assignment 9 WAP to generate consecutive NRPS of length ‘n’ using ‘k’ distinct character Input: Read Positive integers - number of characters ‘k’, length of the string ‘n’ and ‘k’ distinct characters. Output: Print NRPS.
  • 10. Assignment 9 What is NRPS?  NRPS means Non-Repetitive Pattern String.
  • 11. Assignment 9 What is NRPS?  NRPS means Non-Repetitive Pattern String.  Example: abcdabdc -> This string is formed using 4 distinct characters ‘a’, ‘b’, ‘c’ and ‘d’ of string length 8.  The pattern should not be repeated consecutively.
  • 12. Assignment 9 How will you check the string is NRPS or not?
  • 13. Assignment 9 How will you check the string is NRPS or not?  Example: abcdabdc -> This string is formed using 4 distinct characters ‘a’, ‘b’, ‘c’ and ‘d’ of string length 8.
  • 14. Assignment 9 How will you check the string is NRPS or not?  Example: abcdabdc -> This string is formed using 4 distinct characters ‘a’, ‘b’, ‘c’ and ‘d’ of string length 8. a b c d a b d c 0 NRPS
  • 15. Assignment 9 How will you check the string is NRPS or not?  Example: abcdabdc -> This string is formed using 4 distinct characters ‘a’, ‘b’, ‘c’ and ‘d’ of string length 8. a b c d a b d c 0 NRPS First pattern is formed using the characters a, b, c and d in order.
  • 16. Assignment 9 How will you check the string is NRPS or not?  Example: abcdabdc -> This string is formed using 4 distinct characters ‘a’, ‘b’, ‘c’ and ‘d’ of string length 8. a b c d a b d c 0 NRPS Next pattern is formed by swapping some characters. The pattern should not be same as previous pattern.
  • 17. Assignment 9 How will you check the string is NRPS or not?  Step 1: Make use of count variable. Initial value of count is 0. count = 0. a b c d a b d c 0 NRPS
  • 18. Assignment 9 How will you check the string is NRPS or not?  Step 2: Start comparing the elements of first pattern and second pattern using their indices. a b c d a b d c 0 NRPS
  • 19. Assignment 9 How will you check the string is NRPS or not?  Step 2: Start from ‘a’ from abcd and ‘a’ from abdc.  If, both are same, increment count by 1 a b c d a b d c 0 NRPS count = 1
  • 20. Assignment 9 How will you check the string is NRPS or not?  Step 2: Then ‘b’ from abcd and ‘b’ from abdc.  If, both are same, increment count by 1 a b c d a b d c 0 NRPS count = 2
  • 21. Assignment 9 How will you check the string is NRPS or not?  Step 2: Then ‘c’ from abcd and ‘d’ from abdc.  If, both are same, increment count by 1  If not, reset the count value to 0. a b c d a b d c 0 NRPS count = 0
  • 22. Assignment 9 How will you check the string is NRPS or not?  Step 2: Then ‘d’ from abcd and ‘c’ from abdc.  If, both are same, increment count by 1  If not, reset the count value to 0. a b c d a b d c 0 NRPS count = 0
  • 23. Assignment 9 How will you check the string is NRPS or not?  Step 3: Check the count value. • If the count value is 0, then the string is NRPS. • If the count value is other then 0, then the string is not NRPS. a b c d a b d c 0 NRPS count = 0
  • 24. Assignment 9 How will you check the string is NRPS or not?  Step 3: Check the count value. • If the count value is 0, then the string is NRPS. • If the count value is other then 0, then the string is not NRPS. • Here, the count value is 0, so, abcdabdc is NRPS. a b c d a b d c 0 NRPS count = 0
  • 25. Assignment 9 How to create a NRPS?
  • 26. Assignment 9 How to create a NRPS?  Read how many distinct characters(k) are required to create NRPS from user. Assume ‘k’ = 3.  Read 3 distinct characters from user i.e., ‘a’, ‘b’ and ‘c’.  Read the length(n) of the string to be formed using ‘k’ distinct characters. n = 6.
  • 27. Assignment 9 How to create a NRPS?  k = 3, n = 6 and characters are ‘a’, ‘b’ and ‘c’.  Step 1: Create the first pattern of characters in order. a b c NRPS
  • 28. Assignment 9 How to create a NRPS?  k = 3, n = 6 and characters are ‘a’, ‘b’ and ‘c’.  Step2: Start creating the next pattern starting from index 1. a b c b NRPS
  • 29. Assignment 9 How to create a NRPS?  k = 3, n = 6 and characters are ‘a’, ‘b’ and ‘c’.  Step2: Next index 2 can be copied to index 4. a b c b c NRPS
  • 30. Assignment 9 How to create a NRPS?  k = 3, n = 6 and characters are ‘a’, ‘b’ and ‘c’.  Step2: When you reach end of the first pattern, start from the beginning again. a b c b c a NRPS
  • 31. Assignment 9 How to create a NRPS?  k = 3, n = 6 and characters are ‘a’, ‘b’ and ‘c’. a b c b c a 0 NRPS
  • 32. Assignment 9 How to create a NRPS?  Read how many distinct characters(k) are required to create NRPS from user. Assume ‘k’ = 3.  Read 3 distinct characters from user i.e., ‘a’, ‘b’ and ‘c’.  Read the length(n) of the string to be formed using ‘k’ distinct characters. n = 9.
  • 33. Assignment 9 How to create a NRPS?  k = 3, n = 9 and characters are ‘a’, ‘b’ and ‘c’.  Step 1: Create the first pattern of characters in order. a b c NRPS
  • 34. Assignment 9 How to create a NRPS?  k = 3, n = 9 and characters are ‘a’, ‘b’ and ‘c’.  Step2: Start creating the next pattern starting from index 1. NRPS a b c b
  • 35. Assignment 9 How to create a NRPS?  k = 3, n = 9 and characters are ‘a’, ‘b’ and ‘c’.  Step2: Next index 2 can be copied to index 4. NRPS a b c b c
  • 36. Assignment 9 How to create a NRPS?  k = 3, n = 9 and characters are ‘a’, ‘b’ and ‘c’.  Step2: When you reach end of the first pattern, start from the beginning again. NRPS a b c b c a
  • 37. Assignment 9 How to create a NRPS?  k = 3, n = 9 and characters are ‘a’, ‘b’ and ‘c’.  Step1: Repeat the process to create next pattern till length ‘n’. NRPS a b c b c a c
  • 38. Assignment 9 How to create a NRPS?  k = 3, n = 9 and characters are ‘a’, ‘b’ and ‘c’.  Step1: Repeat the process to create next pattern till length ‘n’. NRPS a b c b c a c a
  • 39. Assignment 9 How to create a NRPS?  k = 3, n = 9 and characters are ‘a’, ‘b’ and ‘c’.  Step1: Repeat the process to create next pattern till length ‘n’. NRPS a b c b c a c a b
  • 40. Assignment 9 How to create a NRPS?  k = 3, n = 8 and characters are ‘a’, ‘b’ and ‘c’. NRPS a b c b c a c a b 0