TheAlgorithms/C++ 1.0.0
All the algorithms implemented in C++
Loading...
Searching...
No Matches
longest_palindromic_subsequence.cpp File Reference

Program to find the Longest Palindormic Subsequence of a string. More...

#include <cassert>
#include <string>
#include <vector>
Include dependency graph for longest_palindromic_subsequence.cpp:

Go to the source code of this file.

Namespaces

namespace  dynamic_programming
 Dynamic Programming algorithms.
 

Functions

std::string dynamic_programming::lps (const std::string &a)
 Function that returns the longest palindromic subsequence of a string.
 
static void test ()
 Self-test implementations.
 
int main ()
 Main Function.
 

Detailed Description

Program to find the Longest Palindormic Subsequence of a string.

Palindrome string sequence of characters which reads the same backward as forward Subsequence is a sequence that can be derived from another sequence by deleting some or no elements without changing the order of the remaining elements.

Author
Anjali Jha

Definition in file longest_palindromic_subsequence.cpp.

Function Documentation

◆ main()

int main ( void )

Main Function.

Returns
0 on exit

Definition at line 97 of file longest_palindromic_subsequence.cpp.

97 {
98 test(); // execute the tests
99 return 0;
100}
static void test()
Self-test implementations.

◆ test()

static void test ( )
static

Self-test implementations.

Returns
void

Definition at line 86 of file longest_palindromic_subsequence.cpp.

86 {
87 assert(dynamic_programming::lps("radar") == "radar");
88 assert(dynamic_programming::lps("abbcbaa") == "abcba");
89 assert(dynamic_programming::lps("bbbab") == "bbbb");
90 assert(dynamic_programming::lps("") == "");
91}
std::string lps(const std::string &a)
Function that returns the longest palindromic subsequence of a string.