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

More Related Content

What's hot

ARM Architecture
ARM ArchitectureARM Architecture
ARM Architecture
Dwight Sabio
 
RISC-V Introduction
RISC-V IntroductionRISC-V Introduction
RISC-V Introduction
Yi-Hsiu Hsu
 
C# loops
C# loopsC# loops
C Programming - Refresher - Part II
C Programming - Refresher - Part II C Programming - Refresher - Part II
C Programming - Refresher - Part II
Emertxe Information Technologies Pvt Ltd
 
Clanguage
ClanguageClanguage
Clanguage
Vidyacenter
 
Introduction to c programming
Introduction to c programmingIntroduction to c programming
Introduction to c programming
Alpana Gupta
 
C basics
C   basicsC   basics
Arduino presentation
Arduino presentationArduino presentation
Arduino presentation
Michael Senkow
 
Embedded C - Day 1
Embedded C - Day 1Embedded C - Day 1
IF Else logic in c#
IF Else logic in c#IF Else logic in c#
IF Else logic in c#
Ehsan Ehrari
 
Proteus Circuit Simulation
Proteus Circuit SimulationProteus Circuit Simulation
Proteus Circuit Simulation
Abdul Haseeb
 
MVC + ORM (with project implementation)
MVC + ORM (with project implementation)MVC + ORM (with project implementation)
MVC + ORM (with project implementation)
Prateek Chauhan
 
Digital stop watch
Digital stop watchDigital stop watch
Digital stop watch
Sai Malleswar
 
Introduction to Arduino
Introduction to ArduinoIntroduction to Arduino
Introduction to Arduino
Omer Kilic
 
Makeblock mBot User Manual (Engligh Version)
Makeblock mBot User Manual (Engligh Version)Makeblock mBot User Manual (Engligh Version)
Makeblock mBot User Manual (Engligh Version)
Una Tao
 
RISC-V Introduction
RISC-V IntroductionRISC-V Introduction
RISC-V Introduction
RISC-V International
 
WebServices SOAP WSDL and UDDI
WebServices SOAP WSDL and UDDIWebServices SOAP WSDL and UDDI
WebServices SOAP WSDL and UDDI
Rajkattamuri
 
Introduction to AVR Microcontroller
Introduction to AVR Microcontroller Introduction to AVR Microcontroller
Introduction to AVR Microcontroller
Mahmoud Sadat
 
Core Java Tutorials by Mahika Tutorials
Core Java Tutorials by Mahika TutorialsCore Java Tutorials by Mahika Tutorials
Core Java Tutorials by Mahika Tutorials
Mahika Tutorials
 
Modbus over RS485
Modbus over RS485Modbus over RS485
Modbus over RS485
艾鍗科技
 

What's hot (20)

ARM Architecture
ARM ArchitectureARM Architecture
ARM Architecture
 
RISC-V Introduction
RISC-V IntroductionRISC-V Introduction
RISC-V Introduction
 
C# loops
C# loopsC# loops
C# loops
 
C Programming - Refresher - Part II
C Programming - Refresher - Part II C Programming - Refresher - Part II
C Programming - Refresher - Part II
 
Clanguage
ClanguageClanguage
Clanguage
 
Introduction to c programming
Introduction to c programmingIntroduction to c programming
Introduction to c programming
 
C basics
C   basicsC   basics
C basics
 
Arduino presentation
Arduino presentationArduino presentation
Arduino presentation
 
Embedded C - Day 1
Embedded C - Day 1Embedded C - Day 1
Embedded C - Day 1
 
IF Else logic in c#
IF Else logic in c#IF Else logic in c#
IF Else logic in c#
 
Proteus Circuit Simulation
Proteus Circuit SimulationProteus Circuit Simulation
Proteus Circuit Simulation
 
MVC + ORM (with project implementation)
MVC + ORM (with project implementation)MVC + ORM (with project implementation)
MVC + ORM (with project implementation)
 
Digital stop watch
Digital stop watchDigital stop watch
Digital stop watch
 
Introduction to Arduino
Introduction to ArduinoIntroduction to Arduino
Introduction to Arduino
 
Makeblock mBot User Manual (Engligh Version)
Makeblock mBot User Manual (Engligh Version)Makeblock mBot User Manual (Engligh Version)
Makeblock mBot User Manual (Engligh Version)
 
RISC-V Introduction
RISC-V IntroductionRISC-V Introduction
RISC-V Introduction
 
WebServices SOAP WSDL and UDDI
WebServices SOAP WSDL and UDDIWebServices SOAP WSDL and UDDI
WebServices SOAP WSDL and UDDI
 
Introduction to AVR Microcontroller
Introduction to AVR Microcontroller Introduction to AVR Microcontroller
Introduction to AVR Microcontroller
 
Core Java Tutorials by Mahika Tutorials
Core Java Tutorials by Mahika TutorialsCore Java Tutorials by Mahika Tutorials
Core Java Tutorials by Mahika Tutorials
 
Modbus over RS485
Modbus over RS485Modbus over RS485
Modbus over RS485
 

Similar to 09_nrps.pdf

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
mani123123r
 
String matching algorithm
String matching algorithmString matching algorithm
String matching algorithm
Alokeparna Choudhury
 
06_replace_n_bits_pos.pdf
06_replace_n_bits_pos.pdf06_replace_n_bits_pos.pdf
06_replace_n_bits_pos.pdf
Emertxe Information Technologies Pvt Ltd
 
09_isalnum.pdf
09_isalnum.pdf09_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
Demetrio Ccesa Rayme
 
JMM2016PosterFinal
JMM2016PosterFinalJMM2016PosterFinal
JMM2016PosterFinal
William Campbell
 
Ch-3 lecture.pdf
Ch-3 lecture.pdfCh-3 lecture.pdf
Ch-3 lecture.pdf
TamiratDejene1
 
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 4
Parth Nandedkar
 
Computer Science Exam Help
Computer Science Exam Help Computer Science Exam Help
Computer Science Exam Help
Programming 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)
Neel Shah
 
MultipleObjectDepthMapRec
MultipleObjectDepthMapRecMultipleObjectDepthMapRec
MultipleObjectDepthMapRec
Zachary Job
 
K Means Clustering in ML.pptx
K Means Clustering in ML.pptxK Means Clustering in ML.pptx
K Means Clustering in ML.pptx
Ramakrishna Reddy Bijjam
 
laiba presentation.pptx
laiba presentation.pptxlaiba presentation.pptx
laiba presentation.pptx
AaminaJavid
 

Similar to 09_nrps.pdf (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
 

More from Emertxe Information Technologies Pvt Ltd

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

More from 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
 

Recently uploaded

The basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptxThe basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptx
heathfieldcps1
 
PIMS Job Advertisement 2024.pdf Islamabad
PIMS Job Advertisement 2024.pdf IslamabadPIMS Job Advertisement 2024.pdf Islamabad
PIMS Job Advertisement 2024.pdf Islamabad
AyyanKhan40
 
Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
TechSoup
 
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
Levi Shapiro
 
S1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptxS1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptx
tarandeep35
 
Advanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docxAdvanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docx
adhitya5119
 
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Dr. Vinod Kumar Kanvaria
 
World environment day ppt For 5 June 2024
World environment day ppt For 5 June 2024World environment day ppt For 5 June 2024
World environment day ppt For 5 June 2024
ak6969907
 
Digital Artefact 1 - Tiny Home Environmental Design
Digital Artefact 1 - Tiny Home Environmental DesignDigital Artefact 1 - Tiny Home Environmental Design
Digital Artefact 1 - Tiny Home Environmental Design
amberjdewit93
 
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama UniversityNatural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
Akanksha trivedi rama nursing college kanpur.
 
Film vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movieFilm vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movie
Nicholas Montgomery
 
Pride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School DistrictPride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School District
David Douglas School District
 
Liberal Approach to the Study of Indian Politics.pdf
Liberal Approach to the Study of Indian Politics.pdfLiberal Approach to the Study of Indian Politics.pdf
Liberal Approach to the Study of Indian Politics.pdf
WaniBasim
 
The History of Stoke Newington Street Names
The History of Stoke Newington Street NamesThe History of Stoke Newington Street Names
The History of Stoke Newington Street Names
History of Stoke Newington
 
Azure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHatAzure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHat
Scholarhat
 
clinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdfclinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdf
Priyankaranawat4
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
EverAndrsGuerraGuerr
 
MARY JANE WILSON, A “BOA MÃE” .
MARY JANE WILSON, A “BOA MÃE”           .MARY JANE WILSON, A “BOA MÃE”           .
MARY JANE WILSON, A “BOA MÃE” .
Colégio Santa Teresinha
 
PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.
Dr. Shivangi Singh Parihar
 
MATATAG CURRICULUM: ASSESSING THE READINESS OF ELEM. PUBLIC SCHOOL TEACHERS I...
MATATAG CURRICULUM: ASSESSING THE READINESS OF ELEM. PUBLIC SCHOOL TEACHERS I...MATATAG CURRICULUM: ASSESSING THE READINESS OF ELEM. PUBLIC SCHOOL TEACHERS I...
MATATAG CURRICULUM: ASSESSING THE READINESS OF ELEM. PUBLIC SCHOOL TEACHERS I...
NelTorrente
 

Recently uploaded (20)

The basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptxThe basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptx
 
PIMS Job Advertisement 2024.pdf Islamabad
PIMS Job Advertisement 2024.pdf IslamabadPIMS Job Advertisement 2024.pdf Islamabad
PIMS Job Advertisement 2024.pdf Islamabad
 
Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
 
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
 
S1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptxS1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptx
 
Advanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docxAdvanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docx
 
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
 
World environment day ppt For 5 June 2024
World environment day ppt For 5 June 2024World environment day ppt For 5 June 2024
World environment day ppt For 5 June 2024
 
Digital Artefact 1 - Tiny Home Environmental Design
Digital Artefact 1 - Tiny Home Environmental DesignDigital Artefact 1 - Tiny Home Environmental Design
Digital Artefact 1 - Tiny Home Environmental Design
 
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama UniversityNatural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
 
Film vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movieFilm vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movie
 
Pride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School DistrictPride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School District
 
Liberal Approach to the Study of Indian Politics.pdf
Liberal Approach to the Study of Indian Politics.pdfLiberal Approach to the Study of Indian Politics.pdf
Liberal Approach to the Study of Indian Politics.pdf
 
The History of Stoke Newington Street Names
The History of Stoke Newington Street NamesThe History of Stoke Newington Street Names
The History of Stoke Newington Street Names
 
Azure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHatAzure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHat
 
clinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdfclinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdf
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
 
MARY JANE WILSON, A “BOA MÃE” .
MARY JANE WILSON, A “BOA MÃE”           .MARY JANE WILSON, A “BOA MÃE”           .
MARY JANE WILSON, A “BOA MÃE” .
 
PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.
 
MATATAG CURRICULUM: ASSESSING THE READINESS OF ELEM. PUBLIC SCHOOL TEACHERS I...
MATATAG CURRICULUM: ASSESSING THE READINESS OF ELEM. PUBLIC SCHOOL TEACHERS I...MATATAG CURRICULUM: ASSESSING THE READINESS OF ELEM. PUBLIC SCHOOL TEACHERS I...
MATATAG CURRICULUM: ASSESSING THE READINESS OF ELEM. PUBLIC SCHOOL TEACHERS I...
 

09_nrps.pdf

  • 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