diff --git a/Data Structures/Graph/Undirected Graph/UndirectedGraphAdjacenyList.cpp b/Data Structures/Graph/Undirected Graph/UndirectedGraphAdjacenyList.cpp new file mode 100644 index 0000000..09a302a --- /dev/null +++ b/Data Structures/Graph/Undirected Graph/UndirectedGraphAdjacenyList.cpp @@ -0,0 +1,31 @@ +#include +#include +#include +#include +#define Max 10 +using namespace std; +list g[Max]; +void addEdge(int u,int v){ + g[u].push_back(v); + g[v].push_back(u); + +} + +void print(){ + list::iterator ptr; + for(int i=1;i"; + for(ptr=g[i].begin();ptr!=g[i].end();ptr++){ + cout<<*ptr<<" "; + } + cout< +using namespace std; +#define Max 10 +int graph[Max][Max]; +void addEdge(int u,int v){ + graph[u][v]=1; + graph[v][u]=1; +} + +void prints(){ + cout<<" "; + for(int j=1;j=0 and (text[position+j]==pattern[j] or pattern[j]=='_')): + j=j-1 + + if(j==-1): + occurance.append(str(position+1)) + position=position+1 + else: + position=position+ max(1,j-badchar[ord(text[position+j])]) + print("Text:"+text+"\nPattern:"+pattern+"\nTotal Number matched:"+str(len(occurance))+"\nPositions matched:"+', '.join(occurance)) + +def main(): + while (1): + text=input("Enter a sample text:") + pattern=input("Enter a pattern:") + stringSearch(text,pattern) + print("\nEnter 1 to test Continue\nEnter 0 to EXIT") + n=input("Enter your choise: ") + if(n=='0'): + return + + +if __name__=="__main__": + main()