Let's say that a "pair" in a string is two instances of a char separated by a char. So in "AXA" the A's make a pair. Pai

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899604
Joined: Mon Aug 02, 2021 8:13 am

Let's say that a "pair" in a string is two instances of a char separated by a char. So in "AXA" the A's make a pair. Pai

Post by answerhappygod »

Let S Say That A Pair In A String Is Two Instances Of A Char Separated By A Char So In Axa The A S Make A Pair Pai 1
Let S Say That A Pair In A String Is Two Instances Of A Char Separated By A Char So In Axa The A S Make A Pair Pai 1 (91.99 KiB) Viewed 45 times
Let's say that a "pair" in a string is two instances of a char separated by a char. So in "AXA" the A's make a pair. Pair's can overlap, so "AxAxA" contains 3 pairs -- 2 for A and 1 for x. Complete the function below to recursively compute the number of pairs in the given string: int countPairs (char *str) { } Test your function with the following strings. String Correct # of pairs "axa" || 1 "axax" 2 "axbx" || 1 "hi" 10 ["hihih" ||3 1111 "ihihhh"||3 NO 0 Il 11 a "aa" 0 "aaa" | 1 The recursive algorithm should not use any global variables.
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply