-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3523 from issac5693/main1
issue # #3477 - adding a rope datastructure
- Loading branch information
Showing
2 changed files
with
38 additions
and
66 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
38 changes: 38 additions & 0 deletions
38
data_structures/Rope datastructure/python/Rope data structure.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# Python3 program to concatenate two strings | ||
|
||
# Function that concatenates strings a[0..n1-1] | ||
# and b[0..n2-1] and stores the result in c[] | ||
def concatenate(a, b, c, n1, n2): | ||
|
||
# Copy characters of A[] to C[] | ||
i = -1 | ||
for i in range(n1): | ||
c[i] = a[i] | ||
|
||
# Copy characters of B[] | ||
for j in range(n2): | ||
c[i] = b[j] | ||
i += 1 | ||
|
||
# Driver Code | ||
if __name__ == "__main__": | ||
a = "Hi This is geeksforgeeks. " | ||
n1 = len(a) | ||
|
||
b = "You are welcome here." | ||
n2 = len(b) | ||
|
||
a = list(a) | ||
b = list(b) | ||
|
||
# Concatenate a[] and b[] and | ||
# store result in c[] | ||
c = [0] * (n1 + n2 - 1) | ||
|
||
concatenate(a, b, c, n1, n2) | ||
|
||
for i in c: | ||
print(i, end = "") | ||
|
||
# This code is contributed by | ||
# Isaac |