SlideShare une entreprise Scribd logo
1  sur  2
Télécharger pour lire hors ligne
/** Checks whether a given string is a palindrome or not.
*
*@param inputString the string to check for palindrome
*@param ignoreCase a flag to indicate whether case should be ignored when checking for
palindrome
*@return true if the input string is a palindrome, false otherwise
*@throws IllegalArguementException if the input string is null
*
*Example:
*isPalindrome("racecar", true);//returns true
*isPalindrome("Racecar", true); //returns true
*isPalindrome("hello", true); // returns false
*
*/
public static boolean isPalindrome(String inputString, boolean ignoreCase) {
if (inputString == null) {
throw new IllegalArguementException("Input string cannot be null.");
}
int leftIndex = 0;
int rightIndex = inputString.length() -1;
while (leftIndex < rightIndex) {
if (inputString.charAt(leftIndex) != inputString.charAt(rightIndex)) {
return false;
}
leftIndex++;
rightIndex--;
}
return true;
}
Based on the code, answer the following questions: please!
1. Draw the control flow graph that represents abstraction of its execution. Label edges and
nodes in the graph with the corresponding code fragments. (15 points)
Hint-1: Do not forget to indicate initial and end node(s).
Hint-2: You do not need to create a node for the method declaration part in the first line
2. List the test requirements for Node Coverage(3 points)
3. Identify test paths that achieve the test requirements for Node Coverage
4. Give a set of test cases for the test paths in c. Make sure to include test input values and
expected outputs. If it is impossible to design a test case for any test requirements, briefly discuss
why.
5. List the test requirements for Edge Coverage
6.Identify test paths that achieve the test requirements for Edge Coverage
7. Give a set of test cases for the test paths in f. Make sure to include test input values and
expected outputs. If it is impossible to design a test case for any test requirements, briefly discuss
why.

Contenu connexe

Similaire à Checks whether a given string is a palindrome or not. @pa.pdf

JavaScript Qualitätssicherung
JavaScript QualitätssicherungJavaScript Qualitätssicherung
JavaScript Qualitätssicherung
Sebastian Springer
 
Lecture 15_Strings and Dynamic Memory Allocation.pptx
Lecture 15_Strings and  Dynamic Memory Allocation.pptxLecture 15_Strings and  Dynamic Memory Allocation.pptx
Lecture 15_Strings and Dynamic Memory Allocation.pptx
JawadTanvir
 
I am working on java programming that converts zipcode to barcode an.pdf
I am working on java programming that converts zipcode to barcode an.pdfI am working on java programming that converts zipcode to barcode an.pdf
I am working on java programming that converts zipcode to barcode an.pdf
thangarajarivukadal
 
CONTROLSTRUCTURES.ppt
CONTROLSTRUCTURES.pptCONTROLSTRUCTURES.ppt
CONTROLSTRUCTURES.ppt
Sanjjaayyy
 
Csharp In Detail Part2
Csharp In Detail Part2Csharp In Detail Part2
Csharp In Detail Part2
Mohamed Krar
 
java compilerCompiler1.javajava compilerCompiler1.javaimport.docx
java compilerCompiler1.javajava compilerCompiler1.javaimport.docxjava compilerCompiler1.javajava compilerCompiler1.javaimport.docx
java compilerCompiler1.javajava compilerCompiler1.javaimport.docx
priestmanmable
 

Similaire à Checks whether a given string is a palindrome or not. @pa.pdf (20)

Software Quality Testing
Software Quality TestingSoftware Quality Testing
Software Quality Testing
 
C++ boot camp part 1/2
C++ boot camp part 1/2C++ boot camp part 1/2
C++ boot camp part 1/2
 
C++ Boot Camp Part 1
C++ Boot Camp Part 1C++ Boot Camp Part 1
C++ Boot Camp Part 1
 
JavaScript Qualitätssicherung
JavaScript QualitätssicherungJavaScript Qualitätssicherung
JavaScript Qualitätssicherung
 
#include iostream #include string#includeiomanip using.docx
#include iostream #include string#includeiomanip using.docx#include iostream #include string#includeiomanip using.docx
#include iostream #include string#includeiomanip using.docx
 
JAVA Tutorial- Do's and Don'ts of Java programming
JAVA Tutorial- Do's and Don'ts of Java programmingJAVA Tutorial- Do's and Don'ts of Java programming
JAVA Tutorial- Do's and Don'ts of Java programming
 
JAVA Tutorial- Do's and Don'ts of Java programming
JAVA Tutorial- Do's and Don'ts of Java programmingJAVA Tutorial- Do's and Don'ts of Java programming
JAVA Tutorial- Do's and Don'ts of Java programming
 
Go testdeep
Go testdeepGo testdeep
Go testdeep
 
Analysis of Microsoft Code Contracts
Analysis of Microsoft Code ContractsAnalysis of Microsoft Code Contracts
Analysis of Microsoft Code Contracts
 
DotNet programming & Practices
DotNet programming & PracticesDotNet programming & Practices
DotNet programming & Practices
 
Lecture 15_Strings and Dynamic Memory Allocation.pptx
Lecture 15_Strings and  Dynamic Memory Allocation.pptxLecture 15_Strings and  Dynamic Memory Allocation.pptx
Lecture 15_Strings and Dynamic Memory Allocation.pptx
 
Java Puzzlers
Java PuzzlersJava Puzzlers
Java Puzzlers
 
The Art of Java Type Patterns
The Art of Java Type PatternsThe Art of Java Type Patterns
The Art of Java Type Patterns
 
I am working on java programming that converts zipcode to barcode an.pdf
I am working on java programming that converts zipcode to barcode an.pdfI am working on java programming that converts zipcode to barcode an.pdf
I am working on java programming that converts zipcode to barcode an.pdf
 
CONTROLSTRUCTURES.ppt
CONTROLSTRUCTURES.pptCONTROLSTRUCTURES.ppt
CONTROLSTRUCTURES.ppt
 
Kamil witecki asynchronous, yet readable, code
Kamil witecki asynchronous, yet readable, codeKamil witecki asynchronous, yet readable, code
Kamil witecki asynchronous, yet readable, code
 
C programming
C programmingC programming
C programming
 
Control statements-Computer programming
Control statements-Computer programmingControl statements-Computer programming
Control statements-Computer programming
 
Csharp In Detail Part2
Csharp In Detail Part2Csharp In Detail Part2
Csharp In Detail Part2
 
java compilerCompiler1.javajava compilerCompiler1.javaimport.docx
java compilerCompiler1.javajava compilerCompiler1.javaimport.docxjava compilerCompiler1.javajava compilerCompiler1.javaimport.docx
java compilerCompiler1.javajava compilerCompiler1.javaimport.docx
 

Plus de stexfitness

Crossing of two bacteriophages with mutations such as T4 rapid lysis .pdf
 Crossing of two bacteriophages with mutations such as T4 rapid lysis .pdf Crossing of two bacteriophages with mutations such as T4 rapid lysis .pdf
Crossing of two bacteriophages with mutations such as T4 rapid lysis .pdf
stexfitness
 
Con sede en Clichy, Francia, a las afueras de Par�s, LOr�al es l.pdf
 Con sede en Clichy, Francia, a las afueras de Par�s, LOr�al es l.pdf Con sede en Clichy, Francia, a las afueras de Par�s, LOr�al es l.pdf
Con sede en Clichy, Francia, a las afueras de Par�s, LOr�al es l.pdf
stexfitness
 

Plus de stexfitness (20)

Current Attempt in Progress F Your answer is partially correct. The f.pdf
 Current Attempt in Progress F Your answer is partially correct. The f.pdf Current Attempt in Progress F Your answer is partially correct. The f.pdf
Current Attempt in Progress F Your answer is partially correct. The f.pdf
 
Crossing of two bacteriophages with mutations such as T4 rapid lysis .pdf
 Crossing of two bacteriophages with mutations such as T4 rapid lysis .pdf Crossing of two bacteriophages with mutations such as T4 rapid lysis .pdf
Crossing of two bacteriophages with mutations such as T4 rapid lysis .pdf
 
Create a class to represent a Infant object that inherits from (exten.pdf
 Create a class to represent a Infant object that inherits from (exten.pdf Create a class to represent a Infant object that inherits from (exten.pdf
Create a class to represent a Infant object that inherits from (exten.pdf
 
crah to Morithy Cadh Fixpenies lutio Feet cash fiomes from ooeraing a.pdf
 crah to Morithy Cadh Fixpenies lutio Feet cash fiomes from ooeraing a.pdf crah to Morithy Cadh Fixpenies lutio Feet cash fiomes from ooeraing a.pdf
crah to Morithy Cadh Fixpenies lutio Feet cash fiomes from ooeraing a.pdf
 
Crane Company had the following stockholders equity as of January 1,.pdf
 Crane Company had the following stockholders equity as of January 1,.pdf Crane Company had the following stockholders equity as of January 1,.pdf
Crane Company had the following stockholders equity as of January 1,.pdf
 
Convad Company is one of the worlds leading com refiners. It pro.pdf
 Convad Company is one of the worlds leading com refiners. It pro.pdf Convad Company is one of the worlds leading com refiners. It pro.pdf
Convad Company is one of the worlds leading com refiners. It pro.pdf
 
Contemporary issues in managing dark heritage include i. interpretati.pdf
 Contemporary issues in managing dark heritage include i. interpretati.pdf Contemporary issues in managing dark heritage include i. interpretati.pdf
Contemporary issues in managing dark heritage include i. interpretati.pdf
 
Consider two countries, the Portugal and Spain, that each produce onl.pdf
 Consider two countries, the Portugal and Spain, that each produce onl.pdf Consider two countries, the Portugal and Spain, that each produce onl.pdf
Consider two countries, the Portugal and Spain, that each produce onl.pdf
 
Consider the relative liquidity of the following assets Assets 1. A$.pdf
 Consider the relative liquidity of the following assets Assets 1. A$.pdf Consider the relative liquidity of the following assets Assets 1. A$.pdf
Consider the relative liquidity of the following assets Assets 1. A$.pdf
 
Consider the Poisson probability distribution with =12.6. Determine t.pdf
 Consider the Poisson probability distribution with =12.6. Determine t.pdf Consider the Poisson probability distribution with =12.6. Determine t.pdf
Consider the Poisson probability distribution with =12.6. Determine t.pdf
 
Consider the forwarding table below. Indicate the link interface to w.pdf
 Consider the forwarding table below. Indicate the link interface to w.pdf Consider the forwarding table below. Indicate the link interface to w.pdf
Consider the forwarding table below. Indicate the link interface to w.pdf
 
Consider the following premerger information about Firm X and Firm Y .pdf
 Consider the following premerger information about Firm X and Firm Y .pdf Consider the following premerger information about Firm X and Firm Y .pdf
Consider the following premerger information about Firm X and Firm Y .pdf
 
Consider the following simplified version of the RSA algorithm for pu.pdf
 Consider the following simplified version of the RSA algorithm for pu.pdf Consider the following simplified version of the RSA algorithm for pu.pdf
Consider the following simplified version of the RSA algorithm for pu.pdf
 
Consider the following supply and demand model of good i in region jQ.pdf
 Consider the following supply and demand model of good i in region jQ.pdf Consider the following supply and demand model of good i in region jQ.pdf
Consider the following supply and demand model of good i in region jQ.pdf
 
Consider the following income statement for the Luna Lighting Company.pdf
 Consider the following income statement for the Luna Lighting Company.pdf Consider the following income statement for the Luna Lighting Company.pdf
Consider the following income statement for the Luna Lighting Company.pdf
 
Consider the following a) $20 billion in Canada Savings bonds are in.pdf
 Consider the following a) $20 billion in Canada Savings bonds are in.pdf Consider the following a) $20 billion in Canada Savings bonds are in.pdf
Consider the following a) $20 billion in Canada Savings bonds are in.pdf
 
Consider the following joint distribution of random va a. Find PX(x.pdf
 Consider the following joint distribution of random va a. Find PX(x.pdf Consider the following joint distribution of random va a. Find PX(x.pdf
Consider the following joint distribution of random va a. Find PX(x.pdf
 
Concord Corporation had 606000 sheres of common stock outitanding on .pdf
 Concord Corporation had 606000 sheres of common stock outitanding on .pdf Concord Corporation had 606000 sheres of common stock outitanding on .pdf
Concord Corporation had 606000 sheres of common stock outitanding on .pdf
 
Consider the discrete random variables X1 and X2 with joint probabili.pdf
 Consider the discrete random variables X1 and X2 with joint probabili.pdf Consider the discrete random variables X1 and X2 with joint probabili.pdf
Consider the discrete random variables X1 and X2 with joint probabili.pdf
 
Con sede en Clichy, Francia, a las afueras de Par�s, LOr�al es l.pdf
 Con sede en Clichy, Francia, a las afueras de Par�s, LOr�al es l.pdf Con sede en Clichy, Francia, a las afueras de Par�s, LOr�al es l.pdf
Con sede en Clichy, Francia, a las afueras de Par�s, LOr�al es l.pdf
 

Dernier

Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
fonyou31
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
QucHHunhnh
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
PECB
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
kauryashika82
 

Dernier (20)

microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdf
 
General AI for Medical Educators April 2024
General AI for Medical Educators April 2024General AI for Medical Educators April 2024
General AI for Medical Educators April 2024
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
 
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
 
social pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajansocial pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajan
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpin
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3
 
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
 
9548086042 for call girls in Indira Nagar with room service
9548086042  for call girls in Indira Nagar  with room service9548086042  for call girls in Indira Nagar  with room service
9548086042 for call girls in Indira Nagar with room service
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 

Checks whether a given string is a palindrome or not. @pa.pdf

  • 1. /** Checks whether a given string is a palindrome or not. * *@param inputString the string to check for palindrome *@param ignoreCase a flag to indicate whether case should be ignored when checking for palindrome *@return true if the input string is a palindrome, false otherwise *@throws IllegalArguementException if the input string is null * *Example: *isPalindrome("racecar", true);//returns true *isPalindrome("Racecar", true); //returns true *isPalindrome("hello", true); // returns false * */ public static boolean isPalindrome(String inputString, boolean ignoreCase) { if (inputString == null) { throw new IllegalArguementException("Input string cannot be null."); } int leftIndex = 0; int rightIndex = inputString.length() -1; while (leftIndex < rightIndex) { if (inputString.charAt(leftIndex) != inputString.charAt(rightIndex)) { return false; } leftIndex++; rightIndex--; } return true; } Based on the code, answer the following questions: please! 1. Draw the control flow graph that represents abstraction of its execution. Label edges and nodes in the graph with the corresponding code fragments. (15 points)
  • 2. Hint-1: Do not forget to indicate initial and end node(s). Hint-2: You do not need to create a node for the method declaration part in the first line 2. List the test requirements for Node Coverage(3 points) 3. Identify test paths that achieve the test requirements for Node Coverage 4. Give a set of test cases for the test paths in c. Make sure to include test input values and expected outputs. If it is impossible to design a test case for any test requirements, briefly discuss why. 5. List the test requirements for Edge Coverage 6.Identify test paths that achieve the test requirements for Edge Coverage 7. Give a set of test cases for the test paths in f. Make sure to include test input values and expected outputs. If it is impossible to design a test case for any test requirements, briefly discuss why.